Skip to content

Commit

Permalink
CodeGen from PR 13951 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
Merge 945bbc673a28c374116df89c4113b5fea742566b into 66d52ec
  • Loading branch information
SDKAuto committed Apr 26, 2021
1 parent fef0301 commit cf07a61
Show file tree
Hide file tree
Showing 54 changed files with 934 additions and 319 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include _meta.json
recursive-include tests *.py *.yaml
include *.md
include azure/__init__.py
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"autorest": "3.3.0",
"use": "@autorest/python@5.6.6",
"commit": "d5436c4c431d02ba865517b1a26e053144d5390d",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"autorest_command": "autorest specification/applicationinsights/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.6.6 --version=3.3.0",
"readme": "specification/applicationinsights/resource-manager/readme.md"
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@
# regenerated.
# --------------------------------------------------------------------------

from azure.mgmt.core import ARMPipelineClient
from msrest import Serializer, Deserializer
from typing import TYPE_CHECKING

from azure.mgmt.core import ARMPipelineClient
from azure.profiles import KnownProfiles, ProfileDefinition
from azure.profiles.multiapiclient import MultiApiClientMixin
from msrest import Deserializer, Serializer

from ._configuration import ApplicationInsightsManagementClientConfiguration

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any, Optional

from azure.core.credentials import TokenCredential
from azure.core.pipeline.transport import HttpRequest, HttpResponse

class _SDKClient(object):
def __init__(self, *args, **kwargs):
"""This is a fake class to support current implemetation of MultiApiClientMixin."
Expand All @@ -38,9 +47,10 @@ class ApplicationInsightsManagementClient(MultiApiClientMixin, _SDKClient):
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the target subscription.
:type subscription_id: str
:param str api_version: API version to use if no profile is provided, or if
missing in profile.
:param str base_url: Service URL
: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
:type base_url: str
:param profile: A profile definition, from KnownProfiles to dict.
:type profile: azure.profiles.KnownProfiles
"""
Expand Down Expand Up @@ -75,9 +85,9 @@ def __init__(
self,
credential, # type: "TokenCredential"
subscription_id, # type: str
api_version=None,
base_url=None,
profile=KnownProfiles.default,
api_version=None, # type: Optional[str]
base_url=None, # type: Optional[str]
profile=KnownProfiles.default, # type: KnownProfiles
**kwargs # type: Any
):
if not base_url:
Expand All @@ -101,7 +111,6 @@ def models(cls, api_version=DEFAULT_API_VERSION):
* 2017-10-01: :mod:`v2017_10_01.models<azure.mgmt.applicationinsights.v2017_10_01.models>`
* 2018-05-01-preview: :mod:`v2018_05_01_preview.models<azure.mgmt.applicationinsights.v2018_05_01_preview.models>`
* 2018-06-17-preview: :mod:`v2018_06_17_preview.models<azure.mgmt.applicationinsights.v2018_06_17_preview.models>`
* 2019-09-01-preview: :mod:`v2019_09_01_preview.models<azure.mgmt.applicationinsights.v2019_09_01_preview.models>`
* 2019-10-17-preview: :mod:`v2019_10_17_preview.models<azure.mgmt.applicationinsights.v2019_10_17_preview.models>`
* 2020-02-02-preview: :mod:`v2020_02_02_preview.models<azure.mgmt.applicationinsights.v2020_02_02_preview.models>`
* 2020-03-01-preview: :mod:`v2020_03_01_preview.models<azure.mgmt.applicationinsights.v2020_03_01_preview.models>`
Expand All @@ -119,9 +128,6 @@ def models(cls, api_version=DEFAULT_API_VERSION):
elif api_version == '2018-06-17-preview':
from .v2018_06_17_preview import models
return models
elif api_version == '2019-09-01-preview':
from .v2019_09_01_preview import models
return models
elif api_version == '2019-10-17-preview':
from .v2019_10_17_preview import models
return models
Expand Down Expand Up @@ -368,14 +374,11 @@ def operations(self):
"""Instance depends on the API version:
* 2015-05-01: :class:`Operations<azure.mgmt.applicationinsights.v2015_05_01.operations.Operations>`
* 2019-09-01-preview: :class:`Operations<azure.mgmt.applicationinsights.v2019_09_01_preview.operations.Operations>`
* 2020-06-02-preview: :class:`Operations<azure.mgmt.applicationinsights.v2020_06_02_preview.operations.Operations>`
"""
api_version = self._get_api_version('operations')
if api_version == '2015-05-01':
from .v2015_05_01.operations import Operations as OperationClass
elif api_version == '2019-09-01-preview':
from .v2019_09_01_preview.operations import Operations as OperationClass
elif api_version == '2020-06-02-preview':
from .v2020_06_02_preview.operations import Operations as OperationClass
else:
Expand All @@ -398,32 +401,6 @@ def proactive_detection_configurations(self):
raise ValueError("API version {} does not have operation group 'proactive_detection_configurations'".format(api_version))
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))

@property
def queries(self):
"""Instance depends on the API version:
* 2019-09-01-preview: :class:`QueriesOperations<azure.mgmt.applicationinsights.v2019_09_01_preview.operations.QueriesOperations>`
"""
api_version = self._get_api_version('queries')
if api_version == '2019-09-01-preview':
from .v2019_09_01_preview.operations import QueriesOperations as OperationClass
else:
raise ValueError("API version {} does not have operation group 'queries'".format(api_version))
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))

@property
def query_packs(self):
"""Instance depends on the API version:
* 2019-09-01-preview: :class:`QueryPacksOperations<azure.mgmt.applicationinsights.v2019_09_01_preview.operations.QueryPacksOperations>`
"""
api_version = self._get_api_version('query_packs')
if api_version == '2019-09-01-preview':
from .v2019_09_01_preview.operations import QueryPacksOperations as OperationClass
else:
raise ValueError("API version {} does not have operation group 'query_packs'".format(api_version))
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))

@property
def web_test_locations(self):
"""Instance depends on the API version:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from typing import Any
from typing import TYPE_CHECKING

from azure.core.configuration import Configuration
from azure.core.pipeline import policies
from azure.mgmt.core.policies import ARMHttpLoggingPolicy

from ._version import VERSION

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any

from azure.core.credentials import TokenCredential

class ApplicationInsightsManagementClientConfiguration(Configuration):
"""Configuration for ApplicationInsightsManagementClient.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@
# regenerated.
# --------------------------------------------------------------------------

from azure.mgmt.core import AsyncARMPipelineClient
from msrest import Serializer, Deserializer
from typing import Any, Optional, TYPE_CHECKING

from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
from azure.mgmt.core import AsyncARMPipelineClient
from azure.profiles import KnownProfiles, ProfileDefinition
from azure.profiles.multiapiclient import MultiApiClientMixin
from msrest import Deserializer, Serializer

from ._configuration import ApplicationInsightsManagementClientConfiguration

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."
Expand All @@ -38,9 +45,10 @@ class ApplicationInsightsManagementClient(MultiApiClientMixin, _SDKClient):
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The ID of the target subscription.
:type subscription_id: str
:param str api_version: API version to use if no profile is provided, or if
missing in profile.
:param str base_url: Service URL
: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
:type base_url: str
:param profile: A profile definition, from KnownProfiles to dict.
:type profile: azure.profiles.KnownProfiles
"""
Expand Down Expand Up @@ -73,11 +81,11 @@ class ApplicationInsightsManagementClient(MultiApiClientMixin, _SDKClient):

def __init__(
self,
credential, # type: "AsyncTokenCredential"
subscription_id, # type: str
api_version=None,
base_url=None,
profile=KnownProfiles.default,
credential: "AsyncTokenCredential",
subscription_id: str,
api_version: Optional[str] = None,
base_url: Optional[str] = None,
profile: KnownProfiles = KnownProfiles.default,
**kwargs # type: Any
) -> None:
if not base_url:
Expand All @@ -101,7 +109,6 @@ def models(cls, api_version=DEFAULT_API_VERSION):
* 2017-10-01: :mod:`v2017_10_01.models<azure.mgmt.applicationinsights.v2017_10_01.models>`
* 2018-05-01-preview: :mod:`v2018_05_01_preview.models<azure.mgmt.applicationinsights.v2018_05_01_preview.models>`
* 2018-06-17-preview: :mod:`v2018_06_17_preview.models<azure.mgmt.applicationinsights.v2018_06_17_preview.models>`
* 2019-09-01-preview: :mod:`v2019_09_01_preview.models<azure.mgmt.applicationinsights.v2019_09_01_preview.models>`
* 2019-10-17-preview: :mod:`v2019_10_17_preview.models<azure.mgmt.applicationinsights.v2019_10_17_preview.models>`
* 2020-02-02-preview: :mod:`v2020_02_02_preview.models<azure.mgmt.applicationinsights.v2020_02_02_preview.models>`
* 2020-03-01-preview: :mod:`v2020_03_01_preview.models<azure.mgmt.applicationinsights.v2020_03_01_preview.models>`
Expand All @@ -119,9 +126,6 @@ def models(cls, api_version=DEFAULT_API_VERSION):
elif api_version == '2018-06-17-preview':
from ..v2018_06_17_preview import models
return models
elif api_version == '2019-09-01-preview':
from ..v2019_09_01_preview import models
return models
elif api_version == '2019-10-17-preview':
from ..v2019_10_17_preview import models
return models
Expand Down Expand Up @@ -368,14 +372,11 @@ def operations(self):
"""Instance depends on the API version:
* 2015-05-01: :class:`Operations<azure.mgmt.applicationinsights.v2015_05_01.aio.operations.Operations>`
* 2019-09-01-preview: :class:`Operations<azure.mgmt.applicationinsights.v2019_09_01_preview.aio.operations.Operations>`
* 2020-06-02-preview: :class:`Operations<azure.mgmt.applicationinsights.v2020_06_02_preview.aio.operations.Operations>`
"""
api_version = self._get_api_version('operations')
if api_version == '2015-05-01':
from ..v2015_05_01.aio.operations import Operations as OperationClass
elif api_version == '2019-09-01-preview':
from ..v2019_09_01_preview.aio.operations import Operations as OperationClass
elif api_version == '2020-06-02-preview':
from ..v2020_06_02_preview.aio.operations import Operations as OperationClass
else:
Expand All @@ -398,32 +399,6 @@ def proactive_detection_configurations(self):
raise ValueError("API version {} does not have operation group 'proactive_detection_configurations'".format(api_version))
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))

@property
def queries(self):
"""Instance depends on the API version:
* 2019-09-01-preview: :class:`QueriesOperations<azure.mgmt.applicationinsights.v2019_09_01_preview.aio.operations.QueriesOperations>`
"""
api_version = self._get_api_version('queries')
if api_version == '2019-09-01-preview':
from ..v2019_09_01_preview.aio.operations import QueriesOperations as OperationClass
else:
raise ValueError("API version {} does not have operation group 'queries'".format(api_version))
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))

@property
def query_packs(self):
"""Instance depends on the API version:
* 2019-09-01-preview: :class:`QueryPacksOperations<azure.mgmt.applicationinsights.v2019_09_01_preview.aio.operations.QueryPacksOperations>`
"""
api_version = self._get_api_version('query_packs')
if api_version == '2019-09-01-preview':
from ..v2019_09_01_preview.aio.operations import QueryPacksOperations as OperationClass
else:
raise ValueError("API version {} does not have operation group 'query_packs'".format(api_version))
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))

@property
def web_test_locations(self):
"""Instance depends on the API version:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from typing import Any
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

from .._version import VERSION

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential

class ApplicationInsightsManagementClientConfiguration(Configuration):
"""Configuration for ApplicationInsightsManagementClient.
Expand All @@ -31,8 +34,8 @@ class ApplicationInsightsManagementClientConfiguration(Configuration):

def __init__(
self,
credential, # type: "AsyncTokenCredential"
subscription_id, # type: str
credential: "AsyncTokenCredential",
subscription_id: str,
**kwargs # type: Any
) -> None:
if credential is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ApplicationInsightsManagementClientConfiguration
from .operations import Operations
Expand Down Expand Up @@ -97,6 +98,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(
Expand Down Expand Up @@ -134,6 +136,24 @@ def __init__(
self.my_workbooks = MyWorkbooksOperations(
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
"""
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1),
}
http_request.url = self._client.format_url(http_request.url, **path_format_arguments)
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()
Expand Down
Loading

0 comments on commit cf07a61

Please sign in to comment.