diff --git a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/MANIFEST.in b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/MANIFEST.in index a3cb07df8765..3a9b6517412b 100644 --- a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/MANIFEST.in +++ b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/MANIFEST.in @@ -1,3 +1,4 @@ +include _meta.json recursive-include tests *.py *.yaml include *.md include azure/__init__.py diff --git a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/_meta.json b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/_meta.json new file mode 100644 index 000000000000..87cdef0385e0 --- /dev/null +++ b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.4.2", + "use": [ + "@autorest/python@5.8.1", + "@autorest/modelerfour@4.19.2" + ], + "commit": "9da177769d74a0caa5616af0e36042aa60ad9986", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/workloadmonitor/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.1 --use=@autorest/modelerfour@4.19.2 --version=3.4.2", + "readme": "specification/workloadmonitor/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/_metadata.json b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/_metadata.json index bfd25751f9c4..24eac22c9b3d 100644 --- a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/_metadata.json +++ b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/_metadata.json @@ -8,20 +8,23 @@ "base_url": "\u0027https://management.azure.com\u0027", "custom_base_url": null, "azure_arm": true, - "has_lro_operations": false + "has_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"WorkloadMonitorAPIConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"WorkloadMonitorAPIConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" }, "global_parameters": { - "sync_method": { + "sync": { "credential": { - "method_signature": "credential, # type: \"TokenCredential\"", + "signature": "credential, # type: \"TokenCredential\"", "description": "Credential needed for the client to connect to Azure.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true } }, - "async_method": { + "async": { "credential": { - "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "signature": "credential: \"AsyncTokenCredential\",", "description": "Credential needed for the client to connect to Azure.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true @@ -29,21 +32,61 @@ }, "constant": { }, - "call": "credential" + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "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 + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } }, "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], "credential_default_policy_type": "BearerTokenCredentialPolicy", "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null + "credential_key_header_name": null, + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"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\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", "health_monitors": "HealthMonitorsOperations" - }, - "operation_mixins": { - }, - "sync_imports": "None", - "async_imports": "None" + } } \ No newline at end of file diff --git a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/_version.py b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/_version.py index dfa6ee022f15..e5754a47ce68 100644 --- a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/_version.py +++ b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b2" +VERSION = "1.0.0b1" diff --git a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/_workload_monitor_api.py b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/_workload_monitor_api.py index 8c60167ac48d..084d36ce5374 100644 --- a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/_workload_monitor_api.py +++ b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/_workload_monitor_api.py @@ -16,6 +16,7 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential + from azure.core.pipeline.transport import HttpRequest, HttpResponse from ._configuration import WorkloadMonitorAPIConfiguration from .operations import Operations @@ -49,6 +50,7 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) self.operations = Operations( @@ -56,6 +58,21 @@ def __init__( self.health_monitors = HealthMonitorsOperations( self._client, self._config, self._serialize, self._deserialize) + def _send_request(self, http_request, **kwargs): + # type: (HttpRequest, Any) -> HttpResponse + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.HttpResponse + """ + http_request.url = self._client.format_url(http_request.url) + stream = kwargs.pop("stream", True) + pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + def close(self): # type: () -> None self._client.close() diff --git a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/aio/_workload_monitor_api.py b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/aio/_workload_monitor_api.py index 73aa40a05387..65ce31cc8e9e 100644 --- a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/aio/_workload_monitor_api.py +++ b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/aio/_workload_monitor_api.py @@ -8,6 +8,7 @@ from typing import Any, Optional, TYPE_CHECKING +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer @@ -46,6 +47,7 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) self.operations = Operations( @@ -53,6 +55,20 @@ def __init__( self.health_monitors = HealthMonitorsOperations( self._client, self._config, self._serialize, self._deserialize) + async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + """ + http_request.url = self._client.format_url(http_request.url) + stream = kwargs.pop("stream", True) + pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + async def close(self) -> None: await self._client.close() diff --git a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/aio/operations/_health_monitors_operations.py b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/aio/operations/_health_monitors_operations.py index 948f93cc6668..df7c97015a61 100644 --- a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/aio/operations/_health_monitors_operations.py +++ b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/aio/operations/_health_monitors_operations.py @@ -15,7 +15,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat -from ... import models +from ... import models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -34,7 +34,7 @@ class HealthMonitorsOperations: :param deserializer: An object model deserializer. """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer) -> None: self._client = client @@ -51,8 +51,8 @@ def list( resource_name: str, filter: Optional[str] = None, expand: Optional[str] = None, - **kwargs - ) -> AsyncIterable["models.HealthMonitorList"]: + **kwargs: Any + ) -> AsyncIterable["_models.HealthMonitorList"]: """Get the current health status of all monitors of a virtual machine. Optional parameters: $expand (retrieve the monitor's evidence and configuration) and $filter (filter by monitor name). Get the current health status of all monitors of a virtual machine. Optional parameters: @@ -70,8 +70,8 @@ def list( :type resource_collection_name: str :param resource_name: The name of the virtual machine. :type resource_name: str - :param filter: Optionally filter by monitor name. Example: $filter=monitorName eq 'logical- - disks|C:|disk-free-space-mb.'. + :param filter: Optionally filter by monitor name. Example: $filter=monitorName eq + 'logical-disks|C:|disk-free-space-mb.'. :type filter: str :param expand: Optionally expand the monitor’s evidence and/or configuration. Example: $expand=evidence,configuration. @@ -81,7 +81,7 @@ def list( :rtype: ~azure.core.async_paging.AsyncItemPaged[~workload_monitor_api.models.HealthMonitorList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.HealthMonitorList"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.HealthMonitorList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -134,7 +134,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -154,8 +154,8 @@ async def get( resource_name: str, monitor_id: str, expand: Optional[str] = None, - **kwargs - ) -> "models.HealthMonitor": + **kwargs: Any + ) -> "_models.HealthMonitor": """Get the current health status of a monitor of a virtual machine. Optional parameter: $expand (retrieve the monitor's evidence and configuration). Get the current health status of a monitor of a virtual machine. Optional parameter: $expand @@ -182,7 +182,7 @@ async def get( :rtype: ~workload_monitor_api.models.HealthMonitor :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.HealthMonitor"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.HealthMonitor"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -218,7 +218,7 @@ async def get( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('HealthMonitor', pipeline_response) @@ -241,8 +241,8 @@ def list_state_changes( expand: Optional[str] = None, start_timestamp_utc: Optional[datetime.datetime] = None, end_timestamp_utc: Optional[datetime.datetime] = None, - **kwargs - ) -> AsyncIterable["models.HealthMonitorStateChangeList"]: + **kwargs: Any + ) -> AsyncIterable["_models.HealthMonitorStateChangeList"]: """Get the health state changes of a monitor of a virtual machine within the provided time window (default is the last 24 hours). Optional parameters: $expand (retrieve the monitor's evidence and configuration) and $filter (filter by heartbeat condition). Get the health state changes of a monitor of a virtual machine within the provided time window @@ -276,7 +276,7 @@ def list_state_changes( :rtype: ~azure.core.async_paging.AsyncItemPaged[~workload_monitor_api.models.HealthMonitorStateChangeList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.HealthMonitorStateChangeList"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.HealthMonitorStateChangeList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -334,7 +334,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -355,8 +355,8 @@ async def get_state_change( monitor_id: str, timestamp_unix: str, expand: Optional[str] = None, - **kwargs - ) -> "models.HealthMonitorStateChange": + **kwargs: Any + ) -> "_models.HealthMonitorStateChange": """Get the health state change of a monitor of a virtual machine at the provided timestamp. Optional parameter: $expand (retrieve the monitor's evidence and configuration). Get the health state change of a monitor of a virtual machine at the provided timestamp. @@ -385,7 +385,7 @@ async def get_state_change( :rtype: ~workload_monitor_api.models.HealthMonitorStateChange :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.HealthMonitorStateChange"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.HealthMonitorStateChange"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -422,7 +422,7 @@ async def get_state_change( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('HealthMonitorStateChange', pipeline_response) diff --git a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/aio/operations/_monitors_operations.py b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/aio/operations/_monitors_operations.py deleted file mode 100644 index 1fc775b01f2d..000000000000 --- a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/aio/operations/_monitors_operations.py +++ /dev/null @@ -1,421 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for 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, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class MonitorsOperations: - """MonitorsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~workload_monitor_api.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - subscription_id: str, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - filter: Optional[str] = None, - expand: Optional[str] = None, - **kwargs - ) -> AsyncIterable["models.MonitorList"]: - """Get list of a monitors of a resource (with optional filter). - - Get list of a monitors of a resource (with optional filter). - - :param subscription_id: The subscriptionId of the resource. - :type subscription_id: str - :param resource_group_name: The resourceGroupName of the resource. - :type resource_group_name: str - :param resource_namespace: The resourceNamespace of the resource. - :type resource_namespace: str - :param resource_type: The resourceType of the resource. - :type resource_type: str - :param resource_name: The resourceType of the resource. - :type resource_name: str - :param filter: list example: $filter=monitorName eq 'logical-disks|C:|disk-free-space-mb'; - history example: $filter=isHeartbeat eq false. - :type filter: str - :param expand: ex: $expand=evidence,configuration. - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MonitorList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~workload_monitor_api.models.MonitorList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.MonitorList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-13-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('MonitorList', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(models.DefaultError, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.WorkloadMonitor/monitors'} # type: ignore - - async def get( - self, - subscription_id: str, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - monitor_id: str, - expand: Optional[str] = None, - **kwargs - ) -> "models.Monitor": - """Get the current status of a monitor of a resource. - - Get the current status of a monitor of a resource. - - :param subscription_id: The subscriptionId of the resource. - :type subscription_id: str - :param resource_group_name: The resourceGroupName of the resource. - :type resource_group_name: str - :param resource_namespace: The resourceNamespace of the resource. - :type resource_namespace: str - :param resource_type: The resourceType of the resource. - :type resource_type: str - :param resource_name: The resourceType of the resource. - :type resource_name: str - :param monitor_id: The monitorId of the resource (url encoded). - :type monitor_id: str - :param expand: ex: $expand=evidence,configuration. - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Monitor, or the result of cls(response) - :rtype: ~workload_monitor_api.models.Monitor - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Monitor"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-13-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'monitorId': self._serialize.url("monitor_id", monitor_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.DefaultError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Monitor', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.WorkloadMonitor/monitors/{monitorId}'} # type: ignore - - def list_state_changes( - self, - subscription_id: str, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - monitor_id: str, - filter: Optional[str] = None, - expand: Optional[str] = None, - start_timestamp_utc: Optional[datetime.datetime] = None, - end_timestamp_utc: Optional[datetime.datetime] = None, - **kwargs - ) -> AsyncIterable["models.MonitorStateChangeList"]: - """Get history of a monitor of a resource (with optional filter). - - Get history of a monitor of a resource (with optional filter). - - :param subscription_id: The subscriptionId of the resource. - :type subscription_id: str - :param resource_group_name: The resourceGroupName of the resource. - :type resource_group_name: str - :param resource_namespace: The resourceNamespace of the resource. - :type resource_namespace: str - :param resource_type: The resourceType of the resource. - :type resource_type: str - :param resource_name: The resourceType of the resource. - :type resource_name: str - :param monitor_id: The monitorId of the resource (url encoded). - :type monitor_id: str - :param filter: list example: $filter=monitorName eq 'logical-disks|C:|disk-free-space-mb'; - history example: $filter=isHeartbeat eq false. - :type filter: str - :param expand: ex: $expand=evidence,configuration. - :type expand: str - :param start_timestamp_utc: The start Timestamp for the desired history. - :type start_timestamp_utc: ~datetime.datetime - :param end_timestamp_utc: The end Timestamp for the desired history. - :type end_timestamp_utc: ~datetime.datetime - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MonitorStateChangeList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~workload_monitor_api.models.MonitorStateChangeList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.MonitorStateChangeList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-13-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_state_changes.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'monitorId': self._serialize.url("monitor_id", monitor_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if start_timestamp_utc is not None: - query_parameters['startTimestampUtc'] = self._serialize.query("start_timestamp_utc", start_timestamp_utc, 'iso-8601') - if end_timestamp_utc is not None: - query_parameters['endTimestampUtc'] = self._serialize.query("end_timestamp_utc", end_timestamp_utc, 'iso-8601') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('MonitorStateChangeList', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(models.DefaultError, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_state_changes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.WorkloadMonitor/monitors/{monitorId}/history'} # type: ignore - - async def get_state_change( - self, - subscription_id: str, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - monitor_id: str, - timestamp_unix: str, - expand: Optional[str] = None, - **kwargs - ) -> "models.MonitorStateChange": - """Get the status of a monitor at a specific timestamp in history. - - Get the status of a monitor at a specific timestamp in history. - - :param subscription_id: The subscriptionId of the resource. - :type subscription_id: str - :param resource_group_name: The resourceGroupName of the resource. - :type resource_group_name: str - :param resource_namespace: The resourceNamespace of the resource. - :type resource_namespace: str - :param resource_type: The resourceType of the resource. - :type resource_type: str - :param resource_name: The resourceType of the resource. - :type resource_name: str - :param monitor_id: The monitorId of the resource (url encoded). - :type monitor_id: str - :param timestamp_unix: The timestamp of the state change (Unix format). - :type timestamp_unix: str - :param expand: ex: $expand=evidence,configuration. - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitorStateChange, or the result of cls(response) - :rtype: ~workload_monitor_api.models.MonitorStateChange - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.MonitorStateChange"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-13-preview" - accept = "application/json" - - # Construct URL - url = self.get_state_change.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'monitorId': self._serialize.url("monitor_id", monitor_id, 'str'), - 'timestampUnix': self._serialize.url("timestamp_unix", timestamp_unix, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.DefaultError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('MonitorStateChange', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_state_change.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.WorkloadMonitor/monitors/{monitorId}/history/{timestampUnix}'} # type: ignore diff --git a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/aio/operations/_operations.py b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/aio/operations/_operations.py index e796711712b7..7d4c14369548 100644 --- a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/aio/operations/_operations.py +++ b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/aio/operations/_operations.py @@ -14,7 +14,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat -from ... import models +from ... import models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -33,7 +33,7 @@ class Operations: :param deserializer: An object model deserializer. """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer) -> None: self._client = client @@ -43,8 +43,8 @@ def __init__(self, client, config, serializer, deserializer) -> None: def list( self, - **kwargs - ) -> AsyncIterable["models.OperationList"]: + **kwargs: Any + ) -> AsyncIterable["_models.OperationList"]: """Get a list of all available REST API operations. Get a list of all available REST API operations. @@ -54,7 +54,7 @@ def list( :rtype: ~azure.core.async_paging.AsyncItemPaged[~workload_monitor_api.models.OperationList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.OperationList"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -95,7 +95,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/models/_models.py b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/models/_models.py index b4cc1b92f4f9..6c91d7c729d2 100644 --- a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/models/_models.py +++ b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/models/_models.py @@ -148,10 +148,10 @@ class HealthMonitor(Resource): :param last_reported_timestamp: Timestamp of the monitor's last reported health state. :type last_reported_timestamp: str :param evidence: Evidence validating the monitor's current health state. - :type evidence: object + :type evidence: any :param monitor_configuration: The configuration settings at the time of the monitor's health evaluation. - :type monitor_configuration: object + :type monitor_configuration: any """ _validation = { @@ -249,10 +249,10 @@ class HealthMonitorStateChange(Resource): "Healthy", "Critical", "Warning", "Unknown", "Disabled", "None". :vartype current_monitor_state: str or ~workload_monitor_api.models.HealthState :param evidence: Evidence validating the monitor's current health state. - :type evidence: object + :type evidence: any :param monitor_configuration: The configuration settings at the time of the monitor's health evaluation. - :type monitor_configuration: object + :type monitor_configuration: any """ _validation = { diff --git a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/models/_models_py3.py b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/models/_models_py3.py index 5c7eef2d7c8d..63453d0332fa 100644 --- a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/models/_models_py3.py +++ b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/models/_models_py3.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional +from typing import Any, List, Optional from azure.core.exceptions import HttpResponseError import msrest.serialization @@ -159,10 +159,10 @@ class HealthMonitor(Resource): :param last_reported_timestamp: Timestamp of the monitor's last reported health state. :type last_reported_timestamp: str :param evidence: Evidence validating the monitor's current health state. - :type evidence: object + :type evidence: any :param monitor_configuration: The configuration settings at the time of the monitor's health evaluation. - :type monitor_configuration: object + :type monitor_configuration: any """ _validation = { @@ -200,8 +200,8 @@ def __init__( evaluation_timestamp: Optional[str] = None, current_state_first_observed_timestamp: Optional[str] = None, last_reported_timestamp: Optional[str] = None, - evidence: Optional[object] = None, - monitor_configuration: Optional[object] = None, + evidence: Optional[Any] = None, + monitor_configuration: Optional[Any] = None, **kwargs ): super(HealthMonitor, self).__init__(**kwargs) @@ -273,10 +273,10 @@ class HealthMonitorStateChange(Resource): "Healthy", "Critical", "Warning", "Unknown", "Disabled", "None". :vartype current_monitor_state: str or ~workload_monitor_api.models.HealthState :param evidence: Evidence validating the monitor's current health state. - :type evidence: object + :type evidence: any :param monitor_configuration: The configuration settings at the time of the monitor's health evaluation. - :type monitor_configuration: object + :type monitor_configuration: any """ _validation = { @@ -310,8 +310,8 @@ def __init__( monitored_object: Optional[str] = None, evaluation_timestamp: Optional[str] = None, current_state_first_observed_timestamp: Optional[str] = None, - evidence: Optional[object] = None, - monitor_configuration: Optional[object] = None, + evidence: Optional[Any] = None, + monitor_configuration: Optional[Any] = None, **kwargs ): super(HealthMonitorStateChange, self).__init__(**kwargs) diff --git a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/operations/_health_monitors_operations.py b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/operations/_health_monitors_operations.py index 4e6a6bccf3d6..9f8445a024bd 100644 --- a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/operations/_health_monitors_operations.py +++ b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/operations/_health_monitors_operations.py @@ -15,7 +15,7 @@ from azure.core.pipeline.transport import HttpRequest, HttpResponse from azure.mgmt.core.exceptions import ARMErrorFormat -from .. import models +from .. import models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -38,7 +38,7 @@ class HealthMonitorsOperations(object): :param deserializer: An object model deserializer. """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): self._client = client @@ -57,7 +57,7 @@ def list( expand=None, # type: Optional[str] **kwargs # type: Any ): - # type: (...) -> Iterable["models.HealthMonitorList"] + # type: (...) -> Iterable["_models.HealthMonitorList"] """Get the current health status of all monitors of a virtual machine. Optional parameters: $expand (retrieve the monitor's evidence and configuration) and $filter (filter by monitor name). Get the current health status of all monitors of a virtual machine. Optional parameters: @@ -75,8 +75,8 @@ def list( :type resource_collection_name: str :param resource_name: The name of the virtual machine. :type resource_name: str - :param filter: Optionally filter by monitor name. Example: $filter=monitorName eq 'logical- - disks|C:|disk-free-space-mb.'. + :param filter: Optionally filter by monitor name. Example: $filter=monitorName eq + 'logical-disks|C:|disk-free-space-mb.'. :type filter: str :param expand: Optionally expand the monitor’s evidence and/or configuration. Example: $expand=evidence,configuration. @@ -86,7 +86,7 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~workload_monitor_api.models.HealthMonitorList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.HealthMonitorList"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.HealthMonitorList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -139,7 +139,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -161,7 +161,7 @@ def get( expand=None, # type: Optional[str] **kwargs # type: Any ): - # type: (...) -> "models.HealthMonitor" + # type: (...) -> "_models.HealthMonitor" """Get the current health status of a monitor of a virtual machine. Optional parameter: $expand (retrieve the monitor's evidence and configuration). Get the current health status of a monitor of a virtual machine. Optional parameter: $expand @@ -188,7 +188,7 @@ def get( :rtype: ~workload_monitor_api.models.HealthMonitor :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.HealthMonitor"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.HealthMonitor"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -224,7 +224,7 @@ def get( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('HealthMonitor', pipeline_response) @@ -249,7 +249,7 @@ def list_state_changes( end_timestamp_utc=None, # type: Optional[datetime.datetime] **kwargs # type: Any ): - # type: (...) -> Iterable["models.HealthMonitorStateChangeList"] + # type: (...) -> Iterable["_models.HealthMonitorStateChangeList"] """Get the health state changes of a monitor of a virtual machine within the provided time window (default is the last 24 hours). Optional parameters: $expand (retrieve the monitor's evidence and configuration) and $filter (filter by heartbeat condition). Get the health state changes of a monitor of a virtual machine within the provided time window @@ -283,7 +283,7 @@ def list_state_changes( :rtype: ~azure.core.paging.ItemPaged[~workload_monitor_api.models.HealthMonitorStateChangeList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.HealthMonitorStateChangeList"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.HealthMonitorStateChangeList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -341,7 +341,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -364,7 +364,7 @@ def get_state_change( expand=None, # type: Optional[str] **kwargs # type: Any ): - # type: (...) -> "models.HealthMonitorStateChange" + # type: (...) -> "_models.HealthMonitorStateChange" """Get the health state change of a monitor of a virtual machine at the provided timestamp. Optional parameter: $expand (retrieve the monitor's evidence and configuration). Get the health state change of a monitor of a virtual machine at the provided timestamp. @@ -393,7 +393,7 @@ def get_state_change( :rtype: ~workload_monitor_api.models.HealthMonitorStateChange :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.HealthMonitorStateChange"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.HealthMonitorStateChange"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -430,7 +430,7 @@ def get_state_change( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('HealthMonitorStateChange', pipeline_response) diff --git a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/operations/_monitors_operations.py b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/operations/_monitors_operations.py deleted file mode 100644 index 562e3563b5a8..000000000000 --- a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/operations/_monitors_operations.py +++ /dev/null @@ -1,429 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class MonitorsOperations(object): - """MonitorsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~workload_monitor_api.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - subscription_id, # type: str - resource_group_name, # type: str - resource_namespace, # type: str - resource_type, # type: str - resource_name, # type: str - filter=None, # type: Optional[str] - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.MonitorList"] - """Get list of a monitors of a resource (with optional filter). - - Get list of a monitors of a resource (with optional filter). - - :param subscription_id: The subscriptionId of the resource. - :type subscription_id: str - :param resource_group_name: The resourceGroupName of the resource. - :type resource_group_name: str - :param resource_namespace: The resourceNamespace of the resource. - :type resource_namespace: str - :param resource_type: The resourceType of the resource. - :type resource_type: str - :param resource_name: The resourceType of the resource. - :type resource_name: str - :param filter: list example: $filter=monitorName eq 'logical-disks|C:|disk-free-space-mb'; - history example: $filter=isHeartbeat eq false. - :type filter: str - :param expand: ex: $expand=evidence,configuration. - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MonitorList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~workload_monitor_api.models.MonitorList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.MonitorList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-13-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('MonitorList', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(models.DefaultError, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.WorkloadMonitor/monitors'} # type: ignore - - def get( - self, - subscription_id, # type: str - resource_group_name, # type: str - resource_namespace, # type: str - resource_type, # type: str - resource_name, # type: str - monitor_id, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "models.Monitor" - """Get the current status of a monitor of a resource. - - Get the current status of a monitor of a resource. - - :param subscription_id: The subscriptionId of the resource. - :type subscription_id: str - :param resource_group_name: The resourceGroupName of the resource. - :type resource_group_name: str - :param resource_namespace: The resourceNamespace of the resource. - :type resource_namespace: str - :param resource_type: The resourceType of the resource. - :type resource_type: str - :param resource_name: The resourceType of the resource. - :type resource_name: str - :param monitor_id: The monitorId of the resource (url encoded). - :type monitor_id: str - :param expand: ex: $expand=evidence,configuration. - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Monitor, or the result of cls(response) - :rtype: ~workload_monitor_api.models.Monitor - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Monitor"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-13-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'monitorId': self._serialize.url("monitor_id", monitor_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.DefaultError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Monitor', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.WorkloadMonitor/monitors/{monitorId}'} # type: ignore - - def list_state_changes( - self, - subscription_id, # type: str - resource_group_name, # type: str - resource_namespace, # type: str - resource_type, # type: str - resource_name, # type: str - monitor_id, # type: str - filter=None, # type: Optional[str] - expand=None, # type: Optional[str] - start_timestamp_utc=None, # type: Optional[datetime.datetime] - end_timestamp_utc=None, # type: Optional[datetime.datetime] - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.MonitorStateChangeList"] - """Get history of a monitor of a resource (with optional filter). - - Get history of a monitor of a resource (with optional filter). - - :param subscription_id: The subscriptionId of the resource. - :type subscription_id: str - :param resource_group_name: The resourceGroupName of the resource. - :type resource_group_name: str - :param resource_namespace: The resourceNamespace of the resource. - :type resource_namespace: str - :param resource_type: The resourceType of the resource. - :type resource_type: str - :param resource_name: The resourceType of the resource. - :type resource_name: str - :param monitor_id: The monitorId of the resource (url encoded). - :type monitor_id: str - :param filter: list example: $filter=monitorName eq 'logical-disks|C:|disk-free-space-mb'; - history example: $filter=isHeartbeat eq false. - :type filter: str - :param expand: ex: $expand=evidence,configuration. - :type expand: str - :param start_timestamp_utc: The start Timestamp for the desired history. - :type start_timestamp_utc: ~datetime.datetime - :param end_timestamp_utc: The end Timestamp for the desired history. - :type end_timestamp_utc: ~datetime.datetime - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MonitorStateChangeList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~workload_monitor_api.models.MonitorStateChangeList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.MonitorStateChangeList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-13-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_state_changes.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'monitorId': self._serialize.url("monitor_id", monitor_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if start_timestamp_utc is not None: - query_parameters['startTimestampUtc'] = self._serialize.query("start_timestamp_utc", start_timestamp_utc, 'iso-8601') - if end_timestamp_utc is not None: - query_parameters['endTimestampUtc'] = self._serialize.query("end_timestamp_utc", end_timestamp_utc, 'iso-8601') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('MonitorStateChangeList', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(models.DefaultError, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list_state_changes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.WorkloadMonitor/monitors/{monitorId}/history'} # type: ignore - - def get_state_change( - self, - subscription_id, # type: str - resource_group_name, # type: str - resource_namespace, # type: str - resource_type, # type: str - resource_name, # type: str - monitor_id, # type: str - timestamp_unix, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "models.MonitorStateChange" - """Get the status of a monitor at a specific timestamp in history. - - Get the status of a monitor at a specific timestamp in history. - - :param subscription_id: The subscriptionId of the resource. - :type subscription_id: str - :param resource_group_name: The resourceGroupName of the resource. - :type resource_group_name: str - :param resource_namespace: The resourceNamespace of the resource. - :type resource_namespace: str - :param resource_type: The resourceType of the resource. - :type resource_type: str - :param resource_name: The resourceType of the resource. - :type resource_name: str - :param monitor_id: The monitorId of the resource (url encoded). - :type monitor_id: str - :param timestamp_unix: The timestamp of the state change (Unix format). - :type timestamp_unix: str - :param expand: ex: $expand=evidence,configuration. - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitorStateChange, or the result of cls(response) - :rtype: ~workload_monitor_api.models.MonitorStateChange - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.MonitorStateChange"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-13-preview" - accept = "application/json" - - # Construct URL - url = self.get_state_change.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'monitorId': self._serialize.url("monitor_id", monitor_id, 'str'), - 'timestampUnix': self._serialize.url("timestamp_unix", timestamp_unix, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.DefaultError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('MonitorStateChange', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_state_change.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.WorkloadMonitor/monitors/{monitorId}/history/{timestampUnix}'} # type: ignore diff --git a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/operations/_operations.py b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/operations/_operations.py index c748c929696b..eba516133f44 100644 --- a/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/operations/_operations.py +++ b/sdk/workloadmonitor/azure-mgmt-workloadmonitor/azure/mgmt/workloadmonitor/operations/_operations.py @@ -14,7 +14,7 @@ from azure.core.pipeline.transport import HttpRequest, HttpResponse from azure.mgmt.core.exceptions import ARMErrorFormat -from .. import models +from .. import models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -37,7 +37,7 @@ class Operations(object): :param deserializer: An object model deserializer. """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): self._client = client @@ -49,7 +49,7 @@ def list( self, **kwargs # type: Any ): - # type: (...) -> Iterable["models.OperationList"] + # type: (...) -> Iterable["_models.OperationList"] """Get a list of all available REST API operations. Get a list of all available REST API operations. @@ -59,7 +59,7 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~workload_monitor_api.models.OperationList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.OperationList"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -100,7 +100,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)