From f7a8f4f19071b5dfe9d3e900d74ac8ca672d698c Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 21 May 2021 02:43:02 +0000 Subject: [PATCH 1/2] CodeGen from PR 14451 in Azure/azure-rest-api-specs Updating the Microsoft.Logz.io to consume changes in private repo. (#14451) --- sdk/logz/azure-mgmt-logz/CHANGELOG.md | 5 + sdk/logz/azure-mgmt-logz/MANIFEST.in | 6 + sdk/logz/azure-mgmt-logz/README.md | 27 + sdk/logz/azure-mgmt-logz/_meta.json | 11 + sdk/logz/azure-mgmt-logz/azure/__init__.py | 1 + .../azure-mgmt-logz/azure/mgmt/__init__.py | 1 + .../azure/mgmt/logz/__init__.py | 19 + .../azure/mgmt/logz/_configuration.py | 71 + .../azure/mgmt/logz/_metadata.json | 109 ++ .../azure/mgmt/logz/_microsoft_logz.py | 119 ++ .../azure/mgmt/logz/_version.py | 9 + .../azure/mgmt/logz/aio/__init__.py | 10 + .../azure/mgmt/logz/aio/_configuration.py | 67 + .../azure/mgmt/logz/aio/_microsoft_logz.py | 112 ++ .../mgmt/logz/aio/operations/__init__.py | 25 + .../aio/operations/_monitor_operations.py | 276 ++++ .../aio/operations/_monitors_operations.py | 740 +++++++++++ .../mgmt/logz/aio/operations/_operations.py | 105 ++ .../operations/_single_sign_on_operations.py | 327 +++++ .../aio/operations/_sub_account_operations.py | 851 ++++++++++++ .../_sub_account_tag_rules_operations.py | 342 +++++ .../aio/operations/_tag_rules_operations.py | 326 +++++ .../azure/mgmt/logz/models/__init__.py | 135 ++ .../mgmt/logz/models/_microsoft_logz_enums.py | 106 ++ .../azure/mgmt/logz/models/_models.py | 1066 +++++++++++++++ .../azure/mgmt/logz/models/_models_py3.py | 1181 +++++++++++++++++ .../azure/mgmt/logz/operations/__init__.py | 25 + .../logz/operations/_monitor_operations.py | 283 ++++ .../logz/operations/_monitors_operations.py | 754 +++++++++++ .../azure/mgmt/logz/operations/_operations.py | 110 ++ .../operations/_single_sign_on_operations.py | 335 +++++ .../operations/_sub_account_operations.py | 866 ++++++++++++ .../_sub_account_tag_rules_operations.py | 350 +++++ .../logz/operations/_tag_rules_operations.py | 334 +++++ .../azure-mgmt-logz/azure/mgmt/logz/py.typed | 1 + sdk/logz/azure-mgmt-logz/sdk_packaging.toml | 9 + sdk/logz/azure-mgmt-logz/setup.cfg | 2 + sdk/logz/azure-mgmt-logz/setup.py | 91 ++ sdk/logz/ci.yml | 35 + 39 files changed, 9242 insertions(+) create mode 100644 sdk/logz/azure-mgmt-logz/CHANGELOG.md create mode 100644 sdk/logz/azure-mgmt-logz/MANIFEST.in create mode 100644 sdk/logz/azure-mgmt-logz/README.md create mode 100644 sdk/logz/azure-mgmt-logz/_meta.json create mode 100644 sdk/logz/azure-mgmt-logz/azure/__init__.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/__init__.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/__init__.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_configuration.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_metadata.json create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_microsoft_logz.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_version.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/__init__.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/_configuration.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/_microsoft_logz.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/__init__.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_monitor_operations.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_monitors_operations.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_operations.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_single_sign_on_operations.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_sub_account_operations.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_sub_account_tag_rules_operations.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_tag_rules_operations.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/__init__.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_microsoft_logz_enums.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_models.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_models_py3.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/__init__.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_monitor_operations.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_monitors_operations.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_operations.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_single_sign_on_operations.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_sub_account_operations.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_sub_account_tag_rules_operations.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_tag_rules_operations.py create mode 100644 sdk/logz/azure-mgmt-logz/azure/mgmt/logz/py.typed create mode 100644 sdk/logz/azure-mgmt-logz/sdk_packaging.toml create mode 100644 sdk/logz/azure-mgmt-logz/setup.cfg create mode 100644 sdk/logz/azure-mgmt-logz/setup.py create mode 100644 sdk/logz/ci.yml diff --git a/sdk/logz/azure-mgmt-logz/CHANGELOG.md b/sdk/logz/azure-mgmt-logz/CHANGELOG.md new file mode 100644 index 000000000000..578ed6acf479 --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (1970-01-01) + +* Initial Release diff --git a/sdk/logz/azure-mgmt-logz/MANIFEST.in b/sdk/logz/azure-mgmt-logz/MANIFEST.in new file mode 100644 index 000000000000..3a9b6517412b --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/MANIFEST.in @@ -0,0 +1,6 @@ +include _meta.json +recursive-include tests *.py *.yaml +include *.md +include azure/__init__.py +include azure/mgmt/__init__.py + diff --git a/sdk/logz/azure-mgmt-logz/README.md b/sdk/logz/azure-mgmt-logz/README.md new file mode 100644 index 000000000000..2d9056532bae --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/README.md @@ -0,0 +1,27 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure MyService Management Client Library. +This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + + +# Usage + + +To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) + + + +For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) +Code samples for this package can be found at [MyService Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. +Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + +# Provide Feedback + +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. + + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-logz%2FREADME.png) diff --git a/sdk/logz/azure-mgmt-logz/_meta.json b/sdk/logz/azure-mgmt-logz/_meta.json new file mode 100644 index 000000000000..8f2bc61e2aca --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.4.2", + "use": [ + "@autorest/python@5.8.0", + "@autorest/modelerfour@4.19.1" + ], + "commit": "0142a08c953656b1a172e1c274d9c8334fff4c65", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/logz/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.0 --use=@autorest/modelerfour@4.19.1 --version=3.4.2", + "readme": "specification/logz/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/logz/azure-mgmt-logz/azure/__init__.py b/sdk/logz/azure-mgmt-logz/azure/__init__.py new file mode 100644 index 000000000000..0260537a02bb --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/__init__.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/__init__.py new file mode 100644 index 000000000000..0260537a02bb --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/__init__.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/__init__.py new file mode 100644 index 000000000000..b3d287f58cb3 --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._microsoft_logz import MicrosoftLogz +from ._version import VERSION + +__version__ = VERSION +__all__ = ['MicrosoftLogz'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_configuration.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_configuration.py new file mode 100644 index 000000000000..68f9c71936c9 --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_configuration.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 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 MicrosoftLogzConfiguration(Configuration): + """Configuration for MicrosoftLogz. + + 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. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> 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(MicrosoftLogzConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2020-10-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-logz/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> 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 = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_metadata.json b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_metadata.json new file mode 100644 index 000000000000..ef2d897672f8 --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_metadata.json @@ -0,0 +1,109 @@ +{ + "chosen_version": "2020-10-01-preview", + "total_api_version_list": ["2020-10-01-preview"], + "client": { + "name": "MicrosoftLogz", + "filename": "_microsoft_logz", + "description": "MicrosoftLogz.", + "base_url": "\u0027https://management.azure.com\u0027", + "custom_base_url": null, + "azure_arm": true, + "has_lro_operations": true, + "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\": [\"MicrosoftLogzConfiguration\"]}}, \"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\": [\"MicrosoftLogzConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "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, + "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": { + "monitors": "MonitorsOperations", + "operations": "Operations", + "tag_rules": "TagRulesOperations", + "single_sign_on": "SingleSignOnOperations", + "sub_account": "SubAccountOperations", + "sub_account_tag_rules": "SubAccountTagRulesOperations", + "monitor": "MonitorOperations" + } +} \ No newline at end of file diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_microsoft_logz.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_microsoft_logz.py new file mode 100644 index 000000000000..53e9748a6b5d --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_microsoft_logz.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. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +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 + +from ._configuration import MicrosoftLogzConfiguration +from .operations import MonitorsOperations +from .operations import Operations +from .operations import TagRulesOperations +from .operations import SingleSignOnOperations +from .operations import SubAccountOperations +from .operations import SubAccountTagRulesOperations +from .operations import MonitorOperations +from . import models + + +class MicrosoftLogz(object): + """MicrosoftLogz. + + :ivar monitors: MonitorsOperations operations + :vartype monitors: microsoft_logz.operations.MonitorsOperations + :ivar operations: Operations operations + :vartype operations: microsoft_logz.operations.Operations + :ivar tag_rules: TagRulesOperations operations + :vartype tag_rules: microsoft_logz.operations.TagRulesOperations + :ivar single_sign_on: SingleSignOnOperations operations + :vartype single_sign_on: microsoft_logz.operations.SingleSignOnOperations + :ivar sub_account: SubAccountOperations operations + :vartype sub_account: microsoft_logz.operations.SubAccountOperations + :ivar sub_account_tag_rules: SubAccountTagRulesOperations operations + :vartype sub_account_tag_rules: microsoft_logz.operations.SubAccountTagRulesOperations + :ivar monitor: MonitorOperations operations + :vartype monitor: microsoft_logz.operations.MonitorOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = MicrosoftLogzConfiguration(credential, subscription_id, **kwargs) + self._client = 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._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.monitors = MonitorsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + self.tag_rules = TagRulesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.single_sign_on = SingleSignOnOperations( + self._client, self._config, self._serialize, self._deserialize) + self.sub_account = SubAccountOperations( + self._client, self._config, self._serialize, self._deserialize) + self.sub_account_tag_rules = SubAccountTagRulesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.monitor = MonitorOperations( + 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() + + def __enter__(self): + # type: () -> MicrosoftLogz + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_version.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_version.py @@ -0,0 +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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/__init__.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/__init__.py new file mode 100644 index 000000000000..dca956cbd29f --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/__init__.py @@ -0,0 +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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._microsoft_logz import MicrosoftLogz +__all__ = ['MicrosoftLogz'] diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/_configuration.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/_configuration.py new file mode 100644 index 000000000000..72811580bc81 --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/_configuration.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 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 MicrosoftLogzConfiguration(Configuration): + """Configuration for MicrosoftLogz. + + 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. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + """ + + 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(MicrosoftLogzConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2020-10-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-logz/{}'.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 = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/_microsoft_logz.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/_microsoft_logz.py new file mode 100644 index 000000000000..3ab07f0c6fb1 --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/_microsoft_logz.py @@ -0,0 +1,112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code 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, Optional, TYPE_CHECKING + +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration import MicrosoftLogzConfiguration +from .operations import MonitorsOperations +from .operations import Operations +from .operations import TagRulesOperations +from .operations import SingleSignOnOperations +from .operations import SubAccountOperations +from .operations import SubAccountTagRulesOperations +from .operations import MonitorOperations +from .. import models + + +class MicrosoftLogz(object): + """MicrosoftLogz. + + :ivar monitors: MonitorsOperations operations + :vartype monitors: microsoft_logz.aio.operations.MonitorsOperations + :ivar operations: Operations operations + :vartype operations: microsoft_logz.aio.operations.Operations + :ivar tag_rules: TagRulesOperations operations + :vartype tag_rules: microsoft_logz.aio.operations.TagRulesOperations + :ivar single_sign_on: SingleSignOnOperations operations + :vartype single_sign_on: microsoft_logz.aio.operations.SingleSignOnOperations + :ivar sub_account: SubAccountOperations operations + :vartype sub_account: microsoft_logz.aio.operations.SubAccountOperations + :ivar sub_account_tag_rules: SubAccountTagRulesOperations operations + :vartype sub_account_tag_rules: microsoft_logz.aio.operations.SubAccountTagRulesOperations + :ivar monitor: MonitorOperations operations + :vartype monitor: microsoft_logz.aio.operations.MonitorOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param str base_url: Service URL + :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: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = MicrosoftLogzConfiguration(credential, subscription_id, **kwargs) + self._client = 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._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.monitors = MonitorsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + self.tag_rules = TagRulesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.single_sign_on = SingleSignOnOperations( + self._client, self._config, self._serialize, self._deserialize) + self.sub_account = SubAccountOperations( + self._client, self._config, self._serialize, self._deserialize) + self.sub_account_tag_rules = SubAccountTagRulesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.monitor = MonitorOperations( + 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 + """ + 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 = await self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "MicrosoftLogz": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/__init__.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/__init__.py new file mode 100644 index 000000000000..9c8560a389dc --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/__init__.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._monitors_operations import MonitorsOperations +from ._operations import Operations +from ._tag_rules_operations import TagRulesOperations +from ._single_sign_on_operations import SingleSignOnOperations +from ._sub_account_operations import SubAccountOperations +from ._sub_account_tag_rules_operations import SubAccountTagRulesOperations +from ._monitor_operations import MonitorOperations + +__all__ = [ + 'MonitorsOperations', + 'Operations', + 'TagRulesOperations', + 'SingleSignOnOperations', + 'SubAccountOperations', + 'SubAccountTagRulesOperations', + 'MonitorOperations', +] diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_monitor_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_monitor_operations.py new file mode 100644 index 000000000000..31387d41f14e --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_monitor_operations.py @@ -0,0 +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. +# Code 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, 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 as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class MonitorOperations: + """MonitorOperations 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: ~microsoft_logz.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 + + async def vm_host_payload( + self, + resource_group_name: str, + monitor_name: str, + **kwargs: Any + ) -> "_models.VMExtensionPayload": + """Returns the payload that needs to be passed in the request body for installing Logz.io agent on a VM. + + Returns the payload that needs to be passed in the request body for installing Logz.io agent on + a VM. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VMExtensionPayload, or the result of cls(response) + :rtype: ~microsoft_logz.models.VMExtensionPayload + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMExtensionPayload"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.vm_host_payload.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('VMExtensionPayload', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + vm_host_payload.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/vmHostPayload'} # type: ignore + + def list_vm_host_update( + self, + resource_group_name: str, + monitor_name: str, + body: Optional["_models.VMHostUpdateRequest"] = None, + **kwargs: Any + ) -> AsyncIterable["_models.VMResourcesListResponse"]: + """Sending request to update the collection when Logz.io agent has been installed on a VM for a given monitor. + + Sending request to update the collection when Logz.io agent has been installed on a VM for a + given monitor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param body: Request body to update the collection for agent installed in the given monitor. + :type body: ~microsoft_logz.models.VMHostUpdateRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either VMResourcesListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.VMResourcesListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMResourcesListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = "application/json" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_vm_host_update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'VMHostUpdateRequest') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'VMHostUpdateRequest') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('VMResourcesListResponse', 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.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) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_vm_host_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/vmHostUpdate'} # type: ignore + + def list_vm_hosts( + self, + resource_group_name: str, + monitor_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.VMResourcesListResponse"]: + """List the compute resources currently being monitored by the Logz main account resource. + + List the compute resources currently being monitored by the Logz main account resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either VMResourcesListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.VMResourcesListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMResourcesListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-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_vm_hosts.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + request = self._client.post(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('VMResourcesListResponse', 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.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) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_vm_hosts.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/listVMHosts'} # type: ignore diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_monitors_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_monitors_operations.py new file mode 100644 index 000000000000..c02afcdf91da --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_monitors_operations.py @@ -0,0 +1,740 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code 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, Generic, Optional, TypeVar, Union +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.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _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: ~microsoft_logz.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_monitored_resources( + self, + resource_group_name: str, + monitor_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.MonitoredResourceListResponse"]: + """List the resources currently being monitored by the Logz monitor resource. + + List the resources currently being monitored by the Logz monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MonitoredResourceListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.MonitoredResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoredResourceListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-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_monitored_resources.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + request = self._client.post(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('MonitoredResourceListResponse', 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.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) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_monitored_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/listMonitoredResources'} # type: ignore + + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable["_models.LogzMonitorResourceListResponse"]: + """List all monitors under the specified subscription. + + List all monitors under 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 LogzMonitorResourceListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.LogzMonitorResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResourceListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-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_by_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + 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') + + 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('LogzMonitorResourceListResponse', 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.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) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Logz/monitors'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.LogzMonitorResourceListResponse"]: + """List all monitors under the specified resource group. + + List all monitors under the specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :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 LogzMonitorResourceListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.LogzMonitorResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResourceListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-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_by_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + 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') + + 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('LogzMonitorResourceListResponse', 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.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) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors'} # type: ignore + + async def get( + self, + resource_group_name: str, + monitor_name: str, + **kwargs: Any + ) -> "_models.LogzMonitorResource": + """Get the properties of a specific monitor resource. + + Get the properties of a specific monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogzMonitorResource, or the result of cls(response) + :rtype: ~microsoft_logz.models.LogzMonitorResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + # 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LogzMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}'} # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + monitor_name: str, + body: Optional["_models.LogzMonitorResource"] = None, + **kwargs: Any + ) -> "_models.LogzMonitorResource": + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'LogzMonitorResource') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('LogzMonitorResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('LogzMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}'} # type: ignore + + async def begin_create( + self, + resource_group_name: str, + monitor_name: str, + body: Optional["_models.LogzMonitorResource"] = None, + **kwargs: Any + ) -> AsyncLROPoller["_models.LogzMonitorResource"]: + """Create a monitor resource. + + Create a monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param body: + :type body: ~microsoft_logz.models.LogzMonitorResource + :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 LogzMonitorResource or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~microsoft_logz.models.LogzMonitorResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('LogzMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + monitor_name: str, + body: Optional["_models.LogzMonitorResourceUpdateParameters"] = None, + **kwargs: Any + ) -> "_models.LogzMonitorResource": + """Update a monitor resource. + + Update a monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param body: + :type body: ~microsoft_logz.models.LogzMonitorResourceUpdateParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogzMonitorResource, or the result of cls(response) + :rtype: ~microsoft_logz.models.LogzMonitorResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'LogzMonitorResourceUpdateParameters') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LogzMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + monitor_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(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, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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')) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}'} # type: ignore + + async def begin_delete( + self, + resource_group_name: str, + monitor_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a monitor resource. + + Delete a monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}'} # type: ignore + + def list_user_roles( + self, + resource_group_name: str, + monitor_name: str, + body: Optional["_models.UserRoleRequest"] = None, + **kwargs: Any + ) -> AsyncIterable["_models.UserRoleListResponse"]: + """List the user's roles configured on Logz.io side for the account corresponding to the monitor resource. + + List the user's roles configured on Logz.io side for the account corresponding to the monitor + resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param body: + :type body: ~microsoft_logz.models.UserRoleRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either UserRoleListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.UserRoleListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.UserRoleListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = "application/json" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_user_roles.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'UserRoleRequest') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'UserRoleRequest') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('UserRoleListResponse', 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.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) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_user_roles.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/listUserRoles'} # type: ignore diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_operations.py new file mode 100644 index 000000000000..eb872047d549 --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_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. +# -------------------------------------------------------------------------- +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 as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations 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: ~microsoft_logz.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, + **kwargs: Any + ) -> AsyncIterable["_models.OperationListResult"]: + """List all operations provided by Microsoft.Logz. + + List all operations provided by Microsoft.Logz. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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 + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + 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('OperationListResult', 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.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) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Logz/operations'} # type: ignore diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_single_sign_on_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_single_sign_on_operations.py new file mode 100644 index 000000000000..4b6f543b2cb4 --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_single_sign_on_operations.py @@ -0,0 +1,327 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code 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, Generic, Optional, TypeVar, Union +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.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SingleSignOnOperations: + """SingleSignOnOperations 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: ~microsoft_logz.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, + resource_group_name: str, + monitor_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.LogzSingleSignOnResourceListResponse"]: + """List the single sign-on configurations for a given monitor resource. + + List the single sign-on configurations for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LogzSingleSignOnResourceListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.LogzSingleSignOnResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzSingleSignOnResourceListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-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("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + 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('LogzSingleSignOnResourceListResponse', 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.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) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/singleSignOnConfigurations'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + monitor_name: str, + configuration_name: str, + body: Optional["_models.LogzSingleSignOnResource"] = None, + **kwargs: Any + ) -> "_models.LogzSingleSignOnResource": + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzSingleSignOnResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'configurationName': self._serialize.url("configuration_name", configuration_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'LogzSingleSignOnResource') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('LogzSingleSignOnResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('LogzSingleSignOnResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}'} # type: ignore + + async def begin_create_or_update( + self, + resource_group_name: str, + monitor_name: str, + configuration_name: str, + body: Optional["_models.LogzSingleSignOnResource"] = None, + **kwargs: Any + ) -> AsyncLROPoller["_models.LogzSingleSignOnResource"]: + """Configures single-sign-on for this resource. + + Configures single-sign-on for this resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param configuration_name: + :type configuration_name: str + :param body: + :type body: ~microsoft_logz.models.LogzSingleSignOnResource + :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 LogzSingleSignOnResource or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~microsoft_logz.models.LogzSingleSignOnResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzSingleSignOnResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + configuration_name=configuration_name, + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('LogzSingleSignOnResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + monitor_name: str, + configuration_name: str, + **kwargs: Any + ) -> "_models.LogzSingleSignOnResource": + """Gets the Logz single sign-on resource for the given Monitor. + + Gets the Logz single sign-on resource for the given Monitor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param configuration_name: + :type configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogzSingleSignOnResource, or the result of cls(response) + :rtype: ~microsoft_logz.models.LogzSingleSignOnResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzSingleSignOnResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'configurationName': self._serialize.url("configuration_name", configuration_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') + + # 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LogzSingleSignOnResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}'} # type: ignore diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_sub_account_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_sub_account_operations.py new file mode 100644 index 000000000000..609a2207b9bc --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_sub_account_operations.py @@ -0,0 +1,851 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code 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, Generic, Optional, TypeVar, Union +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.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SubAccountOperations: + """SubAccountOperations 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: ~microsoft_logz.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, + resource_group_name: str, + monitor_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.LogzMonitorResourceListResponse"]: + """List the sub account under a given monitor resource. + + List the sub account under a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LogzMonitorResourceListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.LogzMonitorResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResourceListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-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("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + 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('LogzMonitorResourceListResponse', 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.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) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts'} # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + monitor_name: str, + sub_account_name: str, + body: Optional["_models.LogzMonitorResource"] = None, + **kwargs: Any + ) -> "_models.LogzMonitorResource": + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'LogzMonitorResource') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('LogzMonitorResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('LogzMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + + async def begin_create( + self, + resource_group_name: str, + monitor_name: str, + sub_account_name: str, + body: Optional["_models.LogzMonitorResource"] = None, + **kwargs: Any + ) -> AsyncLROPoller["_models.LogzMonitorResource"]: + """Create sub account under a given monitor resource. + + Create sub account under a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_name: str + :param body: + :type body: ~microsoft_logz.models.LogzMonitorResource + :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 LogzMonitorResource or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~microsoft_logz.models.LogzMonitorResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('LogzMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + monitor_name: str, + sub_account_name: str, + **kwargs: Any + ) -> "_models.LogzMonitorResource": + """Get a sub account under a given monitor resource. + + Get a sub account under a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogzMonitorResource, or the result of cls(response) + :rtype: ~microsoft_logz.models.LogzMonitorResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_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') + + # 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LogzMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + monitor_name: str, + sub_account_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(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, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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')) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + + async def begin_delete( + self, + resource_group_name: str, + monitor_name: str, + sub_account_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a sub account resource. + + Delete a sub account resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + monitor_name: str, + sub_account_name: str, + body: Optional["_models.LogzMonitorResourceUpdateParameters"] = None, + **kwargs: Any + ) -> "_models.LogzMonitorResource": + """Update a monitor resource. + + Update a monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_name: str + :param body: + :type body: ~microsoft_logz.models.LogzMonitorResourceUpdateParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogzMonitorResource, or the result of cls(response) + :rtype: ~microsoft_logz.models.LogzMonitorResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'LogzMonitorResourceUpdateParameters') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LogzMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + + def list_monitored_resources( + self, + resource_group_name: str, + monitor_name: str, + sub_account_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.MonitoredResourceListResponse"]: + """List the resources currently being monitored by the Logz sub account resource. + + List the resources currently being monitored by the Logz sub account resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MonitoredResourceListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.MonitoredResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoredResourceListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-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_monitored_resources.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_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') + + request = self._client.post(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('MonitoredResourceListResponse', 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.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) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_monitored_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/listMonitoredResources'} # type: ignore + + async def vm_host_payload( + self, + resource_group_name: str, + monitor_name: str, + sub_account_name: str, + **kwargs: Any + ) -> "_models.VMExtensionPayload": + """Returns the payload that needs to be passed as a request for installing Logz.io agent on a VM. + + Returns the payload that needs to be passed as a request for installing Logz.io agent on a VM. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VMExtensionPayload, or the result of cls(response) + :rtype: ~microsoft_logz.models.VMExtensionPayload + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMExtensionPayload"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.vm_host_payload.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('VMExtensionPayload', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + vm_host_payload.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/vmHostPayload'} # type: ignore + + def list_vm_host_update( + self, + resource_group_name: str, + monitor_name: str, + sub_account_name: str, + body: Optional["_models.VMHostUpdateRequest"] = None, + **kwargs: Any + ) -> AsyncIterable["_models.VMResourcesListResponse"]: + """Sending request to update the collection when Logz.io agent has been installed on a VM for a given monitor. + + Sending request to update the collection when Logz.io agent has been installed on a VM for a + given monitor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_name: str + :param body: Request body to update the collection for agent installed in the given monitor. + :type body: ~microsoft_logz.models.VMHostUpdateRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either VMResourcesListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.VMResourcesListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMResourcesListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = "application/json" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_vm_host_update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_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') + + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'VMHostUpdateRequest') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'VMHostUpdateRequest') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('VMResourcesListResponse', 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.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) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_vm_host_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/vmHostUpdate'} # type: ignore + + def list_vm_hosts( + self, + resource_group_name: str, + monitor_name: str, + sub_account_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.VMResourcesListResponse"]: + """List the compute resources currently being monitored by the Logz sub account resource. + + List the compute resources currently being monitored by the Logz sub account resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either VMResourcesListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.VMResourcesListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMResourcesListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-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_vm_hosts.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_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') + + request = self._client.post(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('VMResourcesListResponse', 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.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) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_vm_hosts.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/listVMHosts'} # type: ignore diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_sub_account_tag_rules_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_sub_account_tag_rules_operations.py new file mode 100644 index 000000000000..05e7e5cbad3a --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_sub_account_tag_rules_operations.py @@ -0,0 +1,342 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code 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, 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 as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SubAccountTagRulesOperations: + """SubAccountTagRulesOperations 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: ~microsoft_logz.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, + resource_group_name: str, + monitor_name: str, + sub_account_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.MonitoringTagRulesListResponse"]: + """List the tag rules for a given sub account resource. + + List the tag rules for a given sub account resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MonitoringTagRulesListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.MonitoringTagRulesListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringTagRulesListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-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("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_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') + + 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('MonitoringTagRulesListResponse', 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.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) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/tagRules'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + monitor_name: str, + sub_account_name: str, + rule_set_name: str, + body: Optional["_models.MonitoringTagRules"] = None, + **kwargs: Any + ) -> "_models.MonitoringTagRules": + """Create or update a tag rule set for a given sub account resource. + + Create or update a tag rule set for a given sub account resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_name: str + :param rule_set_name: + :type rule_set_name: str + :param body: + :type body: ~microsoft_logz.models.MonitoringTagRules + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MonitoringTagRules, or the result of cls(response) + :rtype: ~microsoft_logz.models.MonitoringTagRules + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringTagRules"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), + 'ruleSetName': self._serialize.url("rule_set_name", rule_set_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'MonitoringTagRules') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('MonitoringTagRules', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/tagRules/{ruleSetName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + monitor_name: str, + sub_account_name: str, + rule_set_name: str, + **kwargs: Any + ) -> "_models.MonitoringTagRules": + """Get a tag rule set for a given monitor resource. + + Get a tag rule set for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_name: str + :param rule_set_name: + :type rule_set_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MonitoringTagRules, or the result of cls(response) + :rtype: ~microsoft_logz.models.MonitoringTagRules + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringTagRules"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), + 'ruleSetName': self._serialize.url("rule_set_name", rule_set_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') + + # 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('MonitoringTagRules', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/tagRules/{ruleSetName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + monitor_name: str, + sub_account_name: str, + rule_set_name: str, + **kwargs: Any + ) -> None: + """Delete a tag rule set for a given monitor resource. + + Delete a tag rule set for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_name: str + :param rule_set_name: + :type rule_set_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 + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), + 'ruleSetName': self._serialize.url("rule_set_name", rule_set_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(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, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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')) + + if cls: + return cls(pipeline_response, None, response_headers) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/tagRules/{ruleSetName}'} # type: ignore diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_tag_rules_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_tag_rules_operations.py new file mode 100644 index 000000000000..a4dd48101394 --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_tag_rules_operations.py @@ -0,0 +1,326 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code 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, 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 as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TagRulesOperations: + """TagRulesOperations 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: ~microsoft_logz.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, + resource_group_name: str, + monitor_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.MonitoringTagRulesListResponse"]: + """List the tag rules for a given monitor resource. + + List the tag rules for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MonitoringTagRulesListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.MonitoringTagRulesListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringTagRulesListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-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("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + 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('MonitoringTagRulesListResponse', 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.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) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/tagRules'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + monitor_name: str, + rule_set_name: str, + body: Optional["_models.MonitoringTagRules"] = None, + **kwargs: Any + ) -> "_models.MonitoringTagRules": + """Create or update a tag rule set for a given monitor resource. + + Create or update a tag rule set for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param rule_set_name: + :type rule_set_name: str + :param body: + :type body: ~microsoft_logz.models.MonitoringTagRules + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MonitoringTagRules, or the result of cls(response) + :rtype: ~microsoft_logz.models.MonitoringTagRules + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringTagRules"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'ruleSetName': self._serialize.url("rule_set_name", rule_set_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'MonitoringTagRules') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('MonitoringTagRules', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/tagRules/{ruleSetName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + monitor_name: str, + rule_set_name: str, + **kwargs: Any + ) -> "_models.MonitoringTagRules": + """Get a tag rule set for a given monitor resource. + + Get a tag rule set for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param rule_set_name: + :type rule_set_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MonitoringTagRules, or the result of cls(response) + :rtype: ~microsoft_logz.models.MonitoringTagRules + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringTagRules"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'ruleSetName': self._serialize.url("rule_set_name", rule_set_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') + + # 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('MonitoringTagRules', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/tagRules/{ruleSetName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + monitor_name: str, + rule_set_name: str, + **kwargs: Any + ) -> None: + """Delete a tag rule set for a given monitor resource. + + Delete a tag rule set for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param rule_set_name: + :type rule_set_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 + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'ruleSetName': self._serialize.url("rule_set_name", rule_set_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(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, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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')) + + if cls: + return cls(pipeline_response, None, response_headers) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/tagRules/{ruleSetName}'} # type: ignore diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/__init__.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/__init__.py new file mode 100644 index 000000000000..d81f9164835e --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/__init__.py @@ -0,0 +1,135 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import ErrorAdditionalInfo + from ._models_py3 import ErrorDetail + from ._models_py3 import ErrorResponse + from ._models_py3 import FilteringTag + from ._models_py3 import IdentityProperties + from ._models_py3 import LogRules + from ._models_py3 import LogzMonitorResource + from ._models_py3 import LogzMonitorResourceListResponse + from ._models_py3 import LogzMonitorResourceUpdateParameters + from ._models_py3 import LogzOrganizationProperties + from ._models_py3 import LogzSingleSignOnProperties + from ._models_py3 import LogzSingleSignOnResource + from ._models_py3 import LogzSingleSignOnResourceListResponse + from ._models_py3 import MonitorProperties + from ._models_py3 import MonitorUpdateProperties + from ._models_py3 import MonitoredResource + from ._models_py3 import MonitoredResourceListResponse + from ._models_py3 import MonitoringTagRules + from ._models_py3 import MonitoringTagRulesListResponse + from ._models_py3 import MonitoringTagRulesProperties + from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult + from ._models_py3 import OperationResult + from ._models_py3 import PlanData + from ._models_py3 import SystemData + from ._models_py3 import UserInfo + from ._models_py3 import UserRoleListResponse + from ._models_py3 import UserRoleRequest + from ._models_py3 import UserRoleResponse + from ._models_py3 import VMExtensionPayload + from ._models_py3 import VMHostUpdateRequest + from ._models_py3 import VMResources + from ._models_py3 import VMResourcesListResponse +except (SyntaxError, ImportError): + from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorDetail # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import FilteringTag # type: ignore + from ._models import IdentityProperties # type: ignore + from ._models import LogRules # type: ignore + from ._models import LogzMonitorResource # type: ignore + from ._models import LogzMonitorResourceListResponse # type: ignore + from ._models import LogzMonitorResourceUpdateParameters # type: ignore + from ._models import LogzOrganizationProperties # type: ignore + from ._models import LogzSingleSignOnProperties # type: ignore + from ._models import LogzSingleSignOnResource # type: ignore + from ._models import LogzSingleSignOnResourceListResponse # type: ignore + from ._models import MonitorProperties # type: ignore + from ._models import MonitorUpdateProperties # type: ignore + from ._models import MonitoredResource # type: ignore + from ._models import MonitoredResourceListResponse # type: ignore + from ._models import MonitoringTagRules # type: ignore + from ._models import MonitoringTagRulesListResponse # type: ignore + from ._models import MonitoringTagRulesProperties # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import OperationResult # type: ignore + from ._models import PlanData # type: ignore + from ._models import SystemData # type: ignore + from ._models import UserInfo # type: ignore + from ._models import UserRoleListResponse # type: ignore + from ._models import UserRoleRequest # type: ignore + from ._models import UserRoleResponse # type: ignore + from ._models import VMExtensionPayload # type: ignore + from ._models import VMHostUpdateRequest # type: ignore + from ._models import VMResources # type: ignore + from ._models import VMResourcesListResponse # type: ignore + +from ._microsoft_logz_enums import ( + CreatedByType, + LiftrResourceCategories, + ManagedIdentityTypes, + MarketplaceSubscriptionStatus, + MonitoringStatus, + ProvisioningState, + SingleSignOnStates, + TagAction, + UserRole, + VMHostUpdateStates, +) + +__all__ = [ + 'ErrorAdditionalInfo', + 'ErrorDetail', + 'ErrorResponse', + 'FilteringTag', + 'IdentityProperties', + 'LogRules', + 'LogzMonitorResource', + 'LogzMonitorResourceListResponse', + 'LogzMonitorResourceUpdateParameters', + 'LogzOrganizationProperties', + 'LogzSingleSignOnProperties', + 'LogzSingleSignOnResource', + 'LogzSingleSignOnResourceListResponse', + 'MonitorProperties', + 'MonitorUpdateProperties', + 'MonitoredResource', + 'MonitoredResourceListResponse', + 'MonitoringTagRules', + 'MonitoringTagRulesListResponse', + 'MonitoringTagRulesProperties', + 'OperationDisplay', + 'OperationListResult', + 'OperationResult', + 'PlanData', + 'SystemData', + 'UserInfo', + 'UserRoleListResponse', + 'UserRoleRequest', + 'UserRoleResponse', + 'VMExtensionPayload', + 'VMHostUpdateRequest', + 'VMResources', + 'VMResourcesListResponse', + 'CreatedByType', + 'LiftrResourceCategories', + 'ManagedIdentityTypes', + 'MarketplaceSubscriptionStatus', + 'MonitoringStatus', + 'ProvisioningState', + 'SingleSignOnStates', + 'TagAction', + 'UserRole', + 'VMHostUpdateStates', +] diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_microsoft_logz_enums.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_microsoft_logz_enums.py new file mode 100644 index 000000000000..87ebc78de4fe --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_microsoft_logz_enums.py @@ -0,0 +1,106 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class LiftrResourceCategories(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + UNKNOWN = "Unknown" + MONITOR_LOGS = "MonitorLogs" + +class ManagedIdentityTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + +class MarketplaceSubscriptionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Flag specifying the Marketplace Subscription Status of the resource. If payment is not made in + time, the resource will go in Suspended state. + """ + + ACTIVE = "Active" + SUSPENDED = "Suspended" + +class MonitoringStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Flag specifying if the resource monitoring is enabled or disabled. + """ + + ENABLED = "Enabled" + DISABLED = "Disabled" + +class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Flag specifying if the resource provisioning state as tracked by ARM. + """ + + ACCEPTED = "Accepted" + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + DELETED = "Deleted" + NOT_SPECIFIED = "NotSpecified" + +class SingleSignOnStates(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Various states of the SSO resource + """ + + INITIAL = "Initial" + ENABLE = "Enable" + DISABLE = "Disable" + EXISTING = "Existing" + +class TagAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Valid actions for a filtering tag. Exclusion takes priority over inclusion. + """ + + INCLUDE = "Include" + EXCLUDE = "Exclude" + +class UserRole(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """User roles on configured in Logz.io account. + """ + + NONE = "None" + USER = "User" + ADMIN = "Admin" + +class VMHostUpdateStates(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Various states of the updating vm extension on resource + """ + + INSTALL = "Install" + DELETE = "Delete" diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_models.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_models.py new file mode 100644 index 000000000000..3f893c547007 --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_models.py @@ -0,0 +1,1066 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.core.exceptions import HttpResponseError +import msrest.serialization + + +class ErrorAdditionalInfo(msrest.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: any + """ + + _validation = { + 'type': {'readonly': True}, + 'info': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'info': {'key': 'info', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorAdditionalInfo, self).__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(msrest.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[~microsoft_logz.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~microsoft_logz.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 + ): + super(ErrorDetail, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(msrest.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.). + + :param error: The error object. + :type error: ~microsoft_logz.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class FilteringTag(msrest.serialization.Model): + """The definition of a filtering tag. Filtering tags are used for capturing resources and include/exclude them from being monitored. + + :param name: The name (also known as the key) of the tag. + :type name: str + :param value: The value of the tag. + :type value: str + :param action: Valid actions for a filtering tag. Exclusion takes priority over inclusion. + Possible values include: "Include", "Exclude". + :type action: str or ~microsoft_logz.models.TagAction + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + 'action': {'key': 'action', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(FilteringTag, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.value = kwargs.get('value', None) + self.action = kwargs.get('action', None) + + +class IdentityProperties(msrest.serialization.Model): + """IdentityProperties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The identity ID. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :param type: Possible values include: "SystemAssigned", "UserAssigned". + :type type: str or ~microsoft_logz.models.ManagedIdentityTypes + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(IdentityProperties, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = kwargs.get('type', None) + + +class LogRules(msrest.serialization.Model): + """Set of rules for sending logs for the Monitor resource. + + :param send_aad_logs: Flag specifying if AAD logs should be sent for the Monitor resource. + :type send_aad_logs: bool + :param send_subscription_logs: Flag specifying if subscription logs should be sent for the + Monitor resource. + :type send_subscription_logs: bool + :param send_activity_logs: Flag specifying if activity logs from Azure resources should be sent + for the Monitor resource. + :type send_activity_logs: bool + :param filtering_tags: List of filtering tags to be used for capturing logs. This only takes + effect if SendActivityLogs flag is enabled. If empty, all resources will be captured. If only + Exclude action is specified, the rules will apply to the list of all available resources. If + Include actions are specified, the rules will only include resources with the associated tags. + :type filtering_tags: list[~microsoft_logz.models.FilteringTag] + """ + + _attribute_map = { + 'send_aad_logs': {'key': 'sendAadLogs', 'type': 'bool'}, + 'send_subscription_logs': {'key': 'sendSubscriptionLogs', 'type': 'bool'}, + 'send_activity_logs': {'key': 'sendActivityLogs', 'type': 'bool'}, + 'filtering_tags': {'key': 'filteringTags', 'type': '[FilteringTag]'}, + } + + def __init__( + self, + **kwargs + ): + super(LogRules, self).__init__(**kwargs) + self.send_aad_logs = kwargs.get('send_aad_logs', None) + self.send_subscription_logs = kwargs.get('send_subscription_logs', None) + self.send_activity_logs = kwargs.get('send_activity_logs', None) + self.filtering_tags = kwargs.get('filtering_tags', None) + + +class LogzMonitorResource(msrest.serialization.Model): + """LogzMonitorResource. + + 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: ARM id of the monitor resource. + :vartype id: str + :ivar system_data: The system metadata relating to this resource. + :vartype system_data: ~microsoft_logz.models.SystemData + :ivar name: Name of the monitor resource. + :vartype name: str + :ivar type: The type of the monitor resource. + :vartype type: str + :param properties: Properties specific to the monitor resource. + :type properties: ~microsoft_logz.models.MonitorProperties + :param identity: + :type identity: ~microsoft_logz.models.IdentityProperties + :param tags: A set of tags. Dictionary of :code:``. + :type tags: dict[str, str] + :param location: Required. + :type location: str + """ + + _validation = { + 'id': {'readonly': True}, + 'system_data': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'MonitorProperties'}, + 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(LogzMonitorResource, self).__init__(**kwargs) + self.id = None + self.system_data = None + self.name = None + self.type = None + self.properties = kwargs.get('properties', None) + self.identity = kwargs.get('identity', None) + self.tags = kwargs.get('tags', None) + self.location = kwargs['location'] + + +class LogzMonitorResourceListResponse(msrest.serialization.Model): + """Response of a list operation. + + :param value: Results of a list operation. + :type value: list[~microsoft_logz.models.LogzMonitorResource] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[LogzMonitorResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(LogzMonitorResourceListResponse, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class LogzMonitorResourceUpdateParameters(msrest.serialization.Model): + """The parameters for a PATCH request to a monitor resource. + + :param properties: The set of properties that can be update in a PATCH request to a monitor + resource. + :type properties: ~microsoft_logz.models.MonitorUpdateProperties + :param tags: A set of tags. The new tags of the monitor resource. + :type tags: dict[str, str] + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'MonitorUpdateProperties'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(LogzMonitorResourceUpdateParameters, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) + self.tags = kwargs.get('tags', None) + + +class LogzOrganizationProperties(msrest.serialization.Model): + """LogzOrganizationProperties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param company_name: Name of the Logz organization. + :type company_name: str + :ivar id: Id of the Logz organization. + :vartype id: str + :param enterprise_app_id: The Id of the Enterprise App used for Single sign on. + :type enterprise_app_id: str + :param single_sign_on_url: The login URL specific to this Logz Organization. + :type single_sign_on_url: str + """ + + _validation = { + 'id': {'readonly': True}, + } + + _attribute_map = { + 'company_name': {'key': 'companyName', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'enterprise_app_id': {'key': 'enterpriseAppId', 'type': 'str'}, + 'single_sign_on_url': {'key': 'singleSignOnUrl', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(LogzOrganizationProperties, self).__init__(**kwargs) + self.company_name = kwargs.get('company_name', None) + self.id = None + self.enterprise_app_id = kwargs.get('enterprise_app_id', None) + self.single_sign_on_url = kwargs.get('single_sign_on_url', None) + + +class LogzSingleSignOnProperties(msrest.serialization.Model): + """LogzSingleSignOnProperties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param single_sign_on_state: Various states of the SSO resource. Possible values include: + "Initial", "Enable", "Disable", "Existing". + :type single_sign_on_state: str or ~microsoft_logz.models.SingleSignOnStates + :param enterprise_app_id: The Id of the Enterprise App used for Single sign-on. + :type enterprise_app_id: str + :param single_sign_on_url: The login URL specific to this Logz Organization. + :type single_sign_on_url: str + :ivar provisioning_state: Flag specifying if the resource provisioning state as tracked by ARM. + Possible values include: "Accepted", "Creating", "Updating", "Deleting", "Succeeded", "Failed", + "Canceled", "Deleted", "NotSpecified". + :vartype provisioning_state: str or ~microsoft_logz.models.ProvisioningState + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'single_sign_on_state': {'key': 'singleSignOnState', 'type': 'str'}, + 'enterprise_app_id': {'key': 'enterpriseAppId', 'type': 'str'}, + 'single_sign_on_url': {'key': 'singleSignOnUrl', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(LogzSingleSignOnProperties, self).__init__(**kwargs) + self.single_sign_on_state = kwargs.get('single_sign_on_state', None) + self.enterprise_app_id = kwargs.get('enterprise_app_id', None) + self.single_sign_on_url = kwargs.get('single_sign_on_url', None) + self.provisioning_state = None + + +class LogzSingleSignOnResource(msrest.serialization.Model): + """LogzSingleSignOnResource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: ARM id of the resource. + :vartype id: str + :ivar name: Name of the configuration. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~microsoft_logz.models.SystemData + :param properties: + :type properties: ~microsoft_logz.models.LogzSingleSignOnProperties + """ + + _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'}, + 'properties': {'key': 'properties', 'type': 'LogzSingleSignOnProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(LogzSingleSignOnResource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + self.properties = kwargs.get('properties', None) + + +class LogzSingleSignOnResourceListResponse(msrest.serialization.Model): + """Response of a list operation. + + :param value: Results of a list operation. + :type value: list[~microsoft_logz.models.LogzSingleSignOnResource] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[LogzSingleSignOnResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(LogzSingleSignOnResourceListResponse, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class MonitoredResource(msrest.serialization.Model): + """The properties of a resource currently being monitored by the Logz monitor resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param id: The ARM id of the resource. + :type id: str + :param sending_metrics: Flag indicating if resource is sending metrics to Logz. + :type sending_metrics: bool + :param reason_for_metrics_status: Reason for why the resource is sending metrics (or why it is + not sending). + :type reason_for_metrics_status: str + :param sending_logs: Flag indicating if resource is sending logs to Logz. + :type sending_logs: bool + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~microsoft_logz.models.SystemData + :param reason_for_logs_status: Reason for why the resource is sending logs (or why it is not + sending). + :type reason_for_logs_status: str + """ + + _validation = { + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'sending_metrics': {'key': 'sendingMetrics', 'type': 'bool'}, + 'reason_for_metrics_status': {'key': 'reasonForMetricsStatus', 'type': 'str'}, + 'sending_logs': {'key': 'sendingLogs', 'type': 'bool'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'reason_for_logs_status': {'key': 'reasonForLogsStatus', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(MonitoredResource, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.sending_metrics = kwargs.get('sending_metrics', None) + self.reason_for_metrics_status = kwargs.get('reason_for_metrics_status', None) + self.sending_logs = kwargs.get('sending_logs', None) + self.system_data = None + self.reason_for_logs_status = kwargs.get('reason_for_logs_status', None) + + +class MonitoredResourceListResponse(msrest.serialization.Model): + """Response of a list operation. + + :param value: Results of a list operation. + :type value: list[~microsoft_logz.models.MonitoredResource] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[MonitoredResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(MonitoredResourceListResponse, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class MonitoringTagRules(msrest.serialization.Model): + """Capture logs and metrics of Azure resources based on ARM tags. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the rule set. + :vartype name: str + :ivar id: The id of the rule set. + :vartype id: str + :ivar type: The type of the rule set. + :vartype type: str + :ivar system_data: The system metadata relating to this resource. + :vartype system_data: ~microsoft_logz.models.SystemData + :param properties: Definition of the properties for a TagRules resource. + :type properties: ~microsoft_logz.models.MonitoringTagRulesProperties + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'properties': {'key': 'properties', 'type': 'MonitoringTagRulesProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(MonitoringTagRules, self).__init__(**kwargs) + self.name = None + self.id = None + self.type = None + self.system_data = None + self.properties = kwargs.get('properties', None) + + +class MonitoringTagRulesListResponse(msrest.serialization.Model): + """Response of a list operation. + + :param value: Results of a list operation. + :type value: list[~microsoft_logz.models.MonitoringTagRules] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[MonitoringTagRules]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(MonitoringTagRulesListResponse, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class MonitoringTagRulesProperties(msrest.serialization.Model): + """Definition of the properties for a TagRules resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Flag specifying if the resource provisioning state as tracked by ARM. + Possible values include: "Accepted", "Creating", "Updating", "Deleting", "Succeeded", "Failed", + "Canceled", "Deleted", "NotSpecified". + :vartype provisioning_state: str or ~microsoft_logz.models.ProvisioningState + :param log_rules: Set of rules for sending logs for the Monitor resource. + :type log_rules: ~microsoft_logz.models.LogRules + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~microsoft_logz.models.SystemData + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'log_rules': {'key': 'logRules', 'type': 'LogRules'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + } + + def __init__( + self, + **kwargs + ): + super(MonitoringTagRulesProperties, self).__init__(**kwargs) + self.provisioning_state = None + self.log_rules = kwargs.get('log_rules', None) + self.system_data = None + + +class MonitorProperties(msrest.serialization.Model): + """Properties specific to the monitor resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Flag specifying if the resource provisioning state as tracked by ARM. + Possible values include: "Accepted", "Creating", "Updating", "Deleting", "Succeeded", "Failed", + "Canceled", "Deleted", "NotSpecified". + :vartype provisioning_state: str or ~microsoft_logz.models.ProvisioningState + :param monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. + Possible values include: "Enabled", "Disabled". + :type monitoring_status: str or ~microsoft_logz.models.MonitoringStatus + :param marketplace_subscription_status: Flag specifying the Marketplace Subscription Status of + the resource. If payment is not made in time, the resource will go in Suspended state. Possible + values include: "Active", "Suspended". + :type marketplace_subscription_status: str or + ~microsoft_logz.models.MarketplaceSubscriptionStatus + :param logz_organization_properties: + :type logz_organization_properties: ~microsoft_logz.models.LogzOrganizationProperties + :param user_info: + :type user_info: ~microsoft_logz.models.UserInfo + :param plan_data: + :type plan_data: ~microsoft_logz.models.PlanData + :ivar liftr_resource_category: Possible values include: "Unknown", "MonitorLogs". + :vartype liftr_resource_category: str or ~microsoft_logz.models.LiftrResourceCategories + :ivar liftr_resource_preference: The priority of the resource. + :vartype liftr_resource_preference: int + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + 'liftr_resource_category': {'readonly': True}, + 'liftr_resource_preference': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'monitoring_status': {'key': 'monitoringStatus', 'type': 'str'}, + 'marketplace_subscription_status': {'key': 'marketplaceSubscriptionStatus', 'type': 'str'}, + 'logz_organization_properties': {'key': 'logzOrganizationProperties', 'type': 'LogzOrganizationProperties'}, + 'user_info': {'key': 'userInfo', 'type': 'UserInfo'}, + 'plan_data': {'key': 'planData', 'type': 'PlanData'}, + 'liftr_resource_category': {'key': 'liftrResourceCategory', 'type': 'str'}, + 'liftr_resource_preference': {'key': 'liftrResourcePreference', 'type': 'int'}, + } + + def __init__( + self, + **kwargs + ): + super(MonitorProperties, self).__init__(**kwargs) + self.provisioning_state = None + self.monitoring_status = kwargs.get('monitoring_status', None) + self.marketplace_subscription_status = kwargs.get('marketplace_subscription_status', None) + self.logz_organization_properties = kwargs.get('logz_organization_properties', None) + self.user_info = kwargs.get('user_info', None) + self.plan_data = kwargs.get('plan_data', None) + self.liftr_resource_category = None + self.liftr_resource_preference = None + + +class MonitorUpdateProperties(msrest.serialization.Model): + """The set of properties that can be update in a PATCH request to a monitor resource. + + :param monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. + Possible values include: "Enabled", "Disabled". + :type monitoring_status: str or ~microsoft_logz.models.MonitoringStatus + """ + + _attribute_map = { + 'monitoring_status': {'key': 'monitoringStatus', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(MonitorUpdateProperties, self).__init__(**kwargs) + self.monitoring_status = kwargs.get('monitoring_status', None) + + +class OperationDisplay(msrest.serialization.Model): + """The object that represents the operation. + + :param provider: Service provider, i.e., Microsoft.Logz. + :type provider: str + :param resource: Type on which the operation is performed, e.g., 'monitors'. + :type resource: str + :param operation: Operation type, e.g., read, write, delete, etc. + :type operation: str + :param description: Description of the operation, e.g., 'Write monitors'. + :type description: str + """ + + _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 + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = kwargs.get('provider', None) + self.resource = kwargs.get('resource', None) + self.operation = kwargs.get('operation', None) + self.description = kwargs.get('description', None) + + +class OperationListResult(msrest.serialization.Model): + """Result of GET request to list the Microsoft.Logz operations. + + :param value: List of operations supported by the Microsoft.Logz provider. + :type value: list[~microsoft_logz.models.OperationResult] + :param next_link: URL to get the next set of operation list results if there are any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[OperationResult]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class OperationResult(msrest.serialization.Model): + """A Microsoft.Logz REST API operation. + + :param name: Operation name, i.e., {provider}/{resource}/{operation}. + :type name: str + :param is_data_action: Indicates whether the operation is a data action. + :type is_data_action: bool + :param display: The object that represents the operation. + :type display: ~microsoft_logz.models.OperationDisplay + :param origin: Origin of the operation. + :type origin: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationResult, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.is_data_action = kwargs.get('is_data_action', None) + self.display = kwargs.get('display', None) + self.origin = kwargs.get('origin', None) + + +class PlanData(msrest.serialization.Model): + """PlanData. + + :param usage_type: different usage type like PAYG/COMMITTED. this could be enum. + :type usage_type: str + :param billing_cycle: different billing cycles like MONTHLY/WEEKLY. this could be enum. + :type billing_cycle: str + :param plan_details: plan id as published by Logz. + :type plan_details: str + :param effective_date: date when plan was applied. + :type effective_date: ~datetime.datetime + """ + + _validation = { + 'usage_type': {'max_length': 50, 'min_length': 0}, + 'billing_cycle': {'max_length': 50, 'min_length': 0}, + 'plan_details': {'max_length': 50, 'min_length': 0}, + } + + _attribute_map = { + 'usage_type': {'key': 'usageType', 'type': 'str'}, + 'billing_cycle': {'key': 'billingCycle', 'type': 'str'}, + 'plan_details': {'key': 'planDetails', 'type': 'str'}, + 'effective_date': {'key': 'effectiveDate', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + super(PlanData, self).__init__(**kwargs) + self.usage_type = kwargs.get('usage_type', None) + self.billing_cycle = kwargs.get('billing_cycle', None) + self.plan_details = kwargs.get('plan_details', None) + self.effective_date = kwargs.get('effective_date', None) + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :type created_by_type: str or ~microsoft_logz.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: ~datetime.datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :type last_modified_by_type: str or ~microsoft_logz.models.CreatedByType + :param last_modified_at: The timestamp of resource last modification (UTC). + :type 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, + **kwargs + ): + super(SystemData, self).__init__(**kwargs) + self.created_by = kwargs.get('created_by', None) + self.created_by_type = kwargs.get('created_by_type', None) + self.created_at = kwargs.get('created_at', None) + self.last_modified_by = kwargs.get('last_modified_by', None) + self.last_modified_by_type = kwargs.get('last_modified_by_type', None) + self.last_modified_at = kwargs.get('last_modified_at', None) + + +class UserInfo(msrest.serialization.Model): + """UserInfo. + + :param first_name: First Name of the user. + :type first_name: str + :param last_name: Last Name of the user. + :type last_name: str + :param email_address: Email of the user used by Logz for contacting them if needed. + :type email_address: str + :param phone_number: Phone number of the user used by Logz for contacting them if needed. + :type phone_number: str + """ + + _validation = { + 'first_name': {'max_length': 50, 'min_length': 0}, + 'last_name': {'max_length': 50, 'min_length': 0}, + 'email_address': {'pattern': r'^[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,}$'}, + 'phone_number': {'max_length': 40, 'min_length': 0}, + } + + _attribute_map = { + 'first_name': {'key': 'firstName', 'type': 'str'}, + 'last_name': {'key': 'lastName', 'type': 'str'}, + 'email_address': {'key': 'emailAddress', 'type': 'str'}, + 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(UserInfo, self).__init__(**kwargs) + self.first_name = kwargs.get('first_name', None) + self.last_name = kwargs.get('last_name', None) + self.email_address = kwargs.get('email_address', None) + self.phone_number = kwargs.get('phone_number', None) + + +class UserRoleListResponse(msrest.serialization.Model): + """Response for list of user's role for Logz.io account. + + :param value: List of user roles for Logz.io account. + :type value: list[~microsoft_logz.models.UserRoleResponse] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[UserRoleResponse]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(UserRoleListResponse, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class UserRoleRequest(msrest.serialization.Model): + """Request for checking user's role for Logz.io account. + + :param email_address: Email of the user used by Logz for contacting them if needed. + :type email_address: str + """ + + _validation = { + 'email_address': {'pattern': r'^[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,}$'}, + } + + _attribute_map = { + 'email_address': {'key': 'emailAddress', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(UserRoleRequest, self).__init__(**kwargs) + self.email_address = kwargs.get('email_address', None) + + +class UserRoleResponse(msrest.serialization.Model): + """Response for checking user's role for Logz.io account. + + :param role: User roles on configured in Logz.io account. Possible values include: "None", + "User", "Admin". + :type role: str or ~microsoft_logz.models.UserRole + """ + + _attribute_map = { + 'role': {'key': 'role', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(UserRoleResponse, self).__init__(**kwargs) + self.role = kwargs.get('role', None) + + +class VMExtensionPayload(msrest.serialization.Model): + """Response of payload to be passed while installing VM agent. + + :param api_key: API Key corresponding to the resource. + :type api_key: str + :param region: Logz.io region where the resource has been created. + :type region: str + """ + + _attribute_map = { + 'api_key': {'key': 'apiKey', 'type': 'str'}, + 'region': {'key': 'region', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(VMExtensionPayload, self).__init__(**kwargs) + self.api_key = kwargs.get('api_key', None) + self.region = kwargs.get('region', None) + + +class VMHostUpdateRequest(msrest.serialization.Model): + """Request of a list VM Host Update Operation. + + :param vm_resource_ids: Request of a list vm host update operation. + :type vm_resource_ids: list[~microsoft_logz.models.VMResources] + :param state: Specifies the state of the operation - install/ delete. Possible values include: + "Install", "Delete". + :type state: str or ~microsoft_logz.models.VMHostUpdateStates + """ + + _attribute_map = { + 'vm_resource_ids': {'key': 'vmResourceIds', 'type': '[VMResources]'}, + 'state': {'key': 'state', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(VMHostUpdateRequest, self).__init__(**kwargs) + self.vm_resource_ids = kwargs.get('vm_resource_ids', None) + self.state = kwargs.get('state', None) + + +class VMResources(msrest.serialization.Model): + """VM Resource Ids. + + :param id: Request of a list vm host update operation. + :type id: str + :param agent_version: Version of the Logz agent installed on the VM. + :type agent_version: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'agent_version': {'key': 'agentVersion', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(VMResources, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.agent_version = kwargs.get('agent_version', None) + + +class VMResourcesListResponse(msrest.serialization.Model): + """Response of a list VM Host Update Operation. + + :param value: Response of a list vm host update operation. + :type value: list[~microsoft_logz.models.VMResources] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[VMResources]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(VMResourcesListResponse, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_models_py3.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_models_py3.py new file mode 100644 index 000000000000..a6c3c45a0041 --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_models_py3.py @@ -0,0 +1,1181 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 Dict, List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._microsoft_logz_enums import * + + +class ErrorAdditionalInfo(msrest.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: any + """ + + _validation = { + 'type': {'readonly': True}, + 'info': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'info': {'key': 'info', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorAdditionalInfo, self).__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(msrest.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[~microsoft_logz.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~microsoft_logz.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 + ): + super(ErrorDetail, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(msrest.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.). + + :param error: The error object. + :type error: ~microsoft_logz.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDetail"] = None, + **kwargs + ): + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class FilteringTag(msrest.serialization.Model): + """The definition of a filtering tag. Filtering tags are used for capturing resources and include/exclude them from being monitored. + + :param name: The name (also known as the key) of the tag. + :type name: str + :param value: The value of the tag. + :type value: str + :param action: Valid actions for a filtering tag. Exclusion takes priority over inclusion. + Possible values include: "Include", "Exclude". + :type action: str or ~microsoft_logz.models.TagAction + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + 'action': {'key': 'action', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + value: Optional[str] = None, + action: Optional[Union[str, "TagAction"]] = None, + **kwargs + ): + super(FilteringTag, self).__init__(**kwargs) + self.name = name + self.value = value + self.action = action + + +class IdentityProperties(msrest.serialization.Model): + """IdentityProperties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The identity ID. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :param type: Possible values include: "SystemAssigned", "UserAssigned". + :type type: str or ~microsoft_logz.models.ManagedIdentityTypes + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "ManagedIdentityTypes"]] = None, + **kwargs + ): + super(IdentityProperties, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + + +class LogRules(msrest.serialization.Model): + """Set of rules for sending logs for the Monitor resource. + + :param send_aad_logs: Flag specifying if AAD logs should be sent for the Monitor resource. + :type send_aad_logs: bool + :param send_subscription_logs: Flag specifying if subscription logs should be sent for the + Monitor resource. + :type send_subscription_logs: bool + :param send_activity_logs: Flag specifying if activity logs from Azure resources should be sent + for the Monitor resource. + :type send_activity_logs: bool + :param filtering_tags: List of filtering tags to be used for capturing logs. This only takes + effect if SendActivityLogs flag is enabled. If empty, all resources will be captured. If only + Exclude action is specified, the rules will apply to the list of all available resources. If + Include actions are specified, the rules will only include resources with the associated tags. + :type filtering_tags: list[~microsoft_logz.models.FilteringTag] + """ + + _attribute_map = { + 'send_aad_logs': {'key': 'sendAadLogs', 'type': 'bool'}, + 'send_subscription_logs': {'key': 'sendSubscriptionLogs', 'type': 'bool'}, + 'send_activity_logs': {'key': 'sendActivityLogs', 'type': 'bool'}, + 'filtering_tags': {'key': 'filteringTags', 'type': '[FilteringTag]'}, + } + + def __init__( + self, + *, + send_aad_logs: Optional[bool] = None, + send_subscription_logs: Optional[bool] = None, + send_activity_logs: Optional[bool] = None, + filtering_tags: Optional[List["FilteringTag"]] = None, + **kwargs + ): + super(LogRules, self).__init__(**kwargs) + self.send_aad_logs = send_aad_logs + self.send_subscription_logs = send_subscription_logs + self.send_activity_logs = send_activity_logs + self.filtering_tags = filtering_tags + + +class LogzMonitorResource(msrest.serialization.Model): + """LogzMonitorResource. + + 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: ARM id of the monitor resource. + :vartype id: str + :ivar system_data: The system metadata relating to this resource. + :vartype system_data: ~microsoft_logz.models.SystemData + :ivar name: Name of the monitor resource. + :vartype name: str + :ivar type: The type of the monitor resource. + :vartype type: str + :param properties: Properties specific to the monitor resource. + :type properties: ~microsoft_logz.models.MonitorProperties + :param identity: + :type identity: ~microsoft_logz.models.IdentityProperties + :param tags: A set of tags. Dictionary of :code:``. + :type tags: dict[str, str] + :param location: Required. + :type location: str + """ + + _validation = { + 'id': {'readonly': True}, + 'system_data': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'MonitorProperties'}, + 'identity': {'key': 'identity', 'type': 'IdentityProperties'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + properties: Optional["MonitorProperties"] = None, + identity: Optional["IdentityProperties"] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(LogzMonitorResource, self).__init__(**kwargs) + self.id = None + self.system_data = None + self.name = None + self.type = None + self.properties = properties + self.identity = identity + self.tags = tags + self.location = location + + +class LogzMonitorResourceListResponse(msrest.serialization.Model): + """Response of a list operation. + + :param value: Results of a list operation. + :type value: list[~microsoft_logz.models.LogzMonitorResource] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[LogzMonitorResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["LogzMonitorResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(LogzMonitorResourceListResponse, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class LogzMonitorResourceUpdateParameters(msrest.serialization.Model): + """The parameters for a PATCH request to a monitor resource. + + :param properties: The set of properties that can be update in a PATCH request to a monitor + resource. + :type properties: ~microsoft_logz.models.MonitorUpdateProperties + :param tags: A set of tags. The new tags of the monitor resource. + :type tags: dict[str, str] + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'MonitorUpdateProperties'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + properties: Optional["MonitorUpdateProperties"] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(LogzMonitorResourceUpdateParameters, self).__init__(**kwargs) + self.properties = properties + self.tags = tags + + +class LogzOrganizationProperties(msrest.serialization.Model): + """LogzOrganizationProperties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param company_name: Name of the Logz organization. + :type company_name: str + :ivar id: Id of the Logz organization. + :vartype id: str + :param enterprise_app_id: The Id of the Enterprise App used for Single sign on. + :type enterprise_app_id: str + :param single_sign_on_url: The login URL specific to this Logz Organization. + :type single_sign_on_url: str + """ + + _validation = { + 'id': {'readonly': True}, + } + + _attribute_map = { + 'company_name': {'key': 'companyName', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'enterprise_app_id': {'key': 'enterpriseAppId', 'type': 'str'}, + 'single_sign_on_url': {'key': 'singleSignOnUrl', 'type': 'str'}, + } + + def __init__( + self, + *, + company_name: Optional[str] = None, + enterprise_app_id: Optional[str] = None, + single_sign_on_url: Optional[str] = None, + **kwargs + ): + super(LogzOrganizationProperties, self).__init__(**kwargs) + self.company_name = company_name + self.id = None + self.enterprise_app_id = enterprise_app_id + self.single_sign_on_url = single_sign_on_url + + +class LogzSingleSignOnProperties(msrest.serialization.Model): + """LogzSingleSignOnProperties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param single_sign_on_state: Various states of the SSO resource. Possible values include: + "Initial", "Enable", "Disable", "Existing". + :type single_sign_on_state: str or ~microsoft_logz.models.SingleSignOnStates + :param enterprise_app_id: The Id of the Enterprise App used for Single sign-on. + :type enterprise_app_id: str + :param single_sign_on_url: The login URL specific to this Logz Organization. + :type single_sign_on_url: str + :ivar provisioning_state: Flag specifying if the resource provisioning state as tracked by ARM. + Possible values include: "Accepted", "Creating", "Updating", "Deleting", "Succeeded", "Failed", + "Canceled", "Deleted", "NotSpecified". + :vartype provisioning_state: str or ~microsoft_logz.models.ProvisioningState + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'single_sign_on_state': {'key': 'singleSignOnState', 'type': 'str'}, + 'enterprise_app_id': {'key': 'enterpriseAppId', 'type': 'str'}, + 'single_sign_on_url': {'key': 'singleSignOnUrl', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + single_sign_on_state: Optional[Union[str, "SingleSignOnStates"]] = None, + enterprise_app_id: Optional[str] = None, + single_sign_on_url: Optional[str] = None, + **kwargs + ): + super(LogzSingleSignOnProperties, self).__init__(**kwargs) + self.single_sign_on_state = single_sign_on_state + self.enterprise_app_id = enterprise_app_id + self.single_sign_on_url = single_sign_on_url + self.provisioning_state = None + + +class LogzSingleSignOnResource(msrest.serialization.Model): + """LogzSingleSignOnResource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: ARM id of the resource. + :vartype id: str + :ivar name: Name of the configuration. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~microsoft_logz.models.SystemData + :param properties: + :type properties: ~microsoft_logz.models.LogzSingleSignOnProperties + """ + + _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'}, + 'properties': {'key': 'properties', 'type': 'LogzSingleSignOnProperties'}, + } + + def __init__( + self, + *, + properties: Optional["LogzSingleSignOnProperties"] = None, + **kwargs + ): + super(LogzSingleSignOnResource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + self.properties = properties + + +class LogzSingleSignOnResourceListResponse(msrest.serialization.Model): + """Response of a list operation. + + :param value: Results of a list operation. + :type value: list[~microsoft_logz.models.LogzSingleSignOnResource] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[LogzSingleSignOnResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["LogzSingleSignOnResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(LogzSingleSignOnResourceListResponse, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class MonitoredResource(msrest.serialization.Model): + """The properties of a resource currently being monitored by the Logz monitor resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param id: The ARM id of the resource. + :type id: str + :param sending_metrics: Flag indicating if resource is sending metrics to Logz. + :type sending_metrics: bool + :param reason_for_metrics_status: Reason for why the resource is sending metrics (or why it is + not sending). + :type reason_for_metrics_status: str + :param sending_logs: Flag indicating if resource is sending logs to Logz. + :type sending_logs: bool + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~microsoft_logz.models.SystemData + :param reason_for_logs_status: Reason for why the resource is sending logs (or why it is not + sending). + :type reason_for_logs_status: str + """ + + _validation = { + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'sending_metrics': {'key': 'sendingMetrics', 'type': 'bool'}, + 'reason_for_metrics_status': {'key': 'reasonForMetricsStatus', 'type': 'str'}, + 'sending_logs': {'key': 'sendingLogs', 'type': 'bool'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'reason_for_logs_status': {'key': 'reasonForLogsStatus', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + sending_metrics: Optional[bool] = None, + reason_for_metrics_status: Optional[str] = None, + sending_logs: Optional[bool] = None, + reason_for_logs_status: Optional[str] = None, + **kwargs + ): + super(MonitoredResource, self).__init__(**kwargs) + self.id = id + self.sending_metrics = sending_metrics + self.reason_for_metrics_status = reason_for_metrics_status + self.sending_logs = sending_logs + self.system_data = None + self.reason_for_logs_status = reason_for_logs_status + + +class MonitoredResourceListResponse(msrest.serialization.Model): + """Response of a list operation. + + :param value: Results of a list operation. + :type value: list[~microsoft_logz.models.MonitoredResource] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[MonitoredResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["MonitoredResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(MonitoredResourceListResponse, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class MonitoringTagRules(msrest.serialization.Model): + """Capture logs and metrics of Azure resources based on ARM tags. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the rule set. + :vartype name: str + :ivar id: The id of the rule set. + :vartype id: str + :ivar type: The type of the rule set. + :vartype type: str + :ivar system_data: The system metadata relating to this resource. + :vartype system_data: ~microsoft_logz.models.SystemData + :param properties: Definition of the properties for a TagRules resource. + :type properties: ~microsoft_logz.models.MonitoringTagRulesProperties + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'properties': {'key': 'properties', 'type': 'MonitoringTagRulesProperties'}, + } + + def __init__( + self, + *, + properties: Optional["MonitoringTagRulesProperties"] = None, + **kwargs + ): + super(MonitoringTagRules, self).__init__(**kwargs) + self.name = None + self.id = None + self.type = None + self.system_data = None + self.properties = properties + + +class MonitoringTagRulesListResponse(msrest.serialization.Model): + """Response of a list operation. + + :param value: Results of a list operation. + :type value: list[~microsoft_logz.models.MonitoringTagRules] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[MonitoringTagRules]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["MonitoringTagRules"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(MonitoringTagRulesListResponse, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class MonitoringTagRulesProperties(msrest.serialization.Model): + """Definition of the properties for a TagRules resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Flag specifying if the resource provisioning state as tracked by ARM. + Possible values include: "Accepted", "Creating", "Updating", "Deleting", "Succeeded", "Failed", + "Canceled", "Deleted", "NotSpecified". + :vartype provisioning_state: str or ~microsoft_logz.models.ProvisioningState + :param log_rules: Set of rules for sending logs for the Monitor resource. + :type log_rules: ~microsoft_logz.models.LogRules + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~microsoft_logz.models.SystemData + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'log_rules': {'key': 'logRules', 'type': 'LogRules'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + } + + def __init__( + self, + *, + log_rules: Optional["LogRules"] = None, + **kwargs + ): + super(MonitoringTagRulesProperties, self).__init__(**kwargs) + self.provisioning_state = None + self.log_rules = log_rules + self.system_data = None + + +class MonitorProperties(msrest.serialization.Model): + """Properties specific to the monitor resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Flag specifying if the resource provisioning state as tracked by ARM. + Possible values include: "Accepted", "Creating", "Updating", "Deleting", "Succeeded", "Failed", + "Canceled", "Deleted", "NotSpecified". + :vartype provisioning_state: str or ~microsoft_logz.models.ProvisioningState + :param monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. + Possible values include: "Enabled", "Disabled". + :type monitoring_status: str or ~microsoft_logz.models.MonitoringStatus + :param marketplace_subscription_status: Flag specifying the Marketplace Subscription Status of + the resource. If payment is not made in time, the resource will go in Suspended state. Possible + values include: "Active", "Suspended". + :type marketplace_subscription_status: str or + ~microsoft_logz.models.MarketplaceSubscriptionStatus + :param logz_organization_properties: + :type logz_organization_properties: ~microsoft_logz.models.LogzOrganizationProperties + :param user_info: + :type user_info: ~microsoft_logz.models.UserInfo + :param plan_data: + :type plan_data: ~microsoft_logz.models.PlanData + :ivar liftr_resource_category: Possible values include: "Unknown", "MonitorLogs". + :vartype liftr_resource_category: str or ~microsoft_logz.models.LiftrResourceCategories + :ivar liftr_resource_preference: The priority of the resource. + :vartype liftr_resource_preference: int + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + 'liftr_resource_category': {'readonly': True}, + 'liftr_resource_preference': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'monitoring_status': {'key': 'monitoringStatus', 'type': 'str'}, + 'marketplace_subscription_status': {'key': 'marketplaceSubscriptionStatus', 'type': 'str'}, + 'logz_organization_properties': {'key': 'logzOrganizationProperties', 'type': 'LogzOrganizationProperties'}, + 'user_info': {'key': 'userInfo', 'type': 'UserInfo'}, + 'plan_data': {'key': 'planData', 'type': 'PlanData'}, + 'liftr_resource_category': {'key': 'liftrResourceCategory', 'type': 'str'}, + 'liftr_resource_preference': {'key': 'liftrResourcePreference', 'type': 'int'}, + } + + def __init__( + self, + *, + monitoring_status: Optional[Union[str, "MonitoringStatus"]] = None, + marketplace_subscription_status: Optional[Union[str, "MarketplaceSubscriptionStatus"]] = None, + logz_organization_properties: Optional["LogzOrganizationProperties"] = None, + user_info: Optional["UserInfo"] = None, + plan_data: Optional["PlanData"] = None, + **kwargs + ): + super(MonitorProperties, self).__init__(**kwargs) + self.provisioning_state = None + self.monitoring_status = monitoring_status + self.marketplace_subscription_status = marketplace_subscription_status + self.logz_organization_properties = logz_organization_properties + self.user_info = user_info + self.plan_data = plan_data + self.liftr_resource_category = None + self.liftr_resource_preference = None + + +class MonitorUpdateProperties(msrest.serialization.Model): + """The set of properties that can be update in a PATCH request to a monitor resource. + + :param monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. + Possible values include: "Enabled", "Disabled". + :type monitoring_status: str or ~microsoft_logz.models.MonitoringStatus + """ + + _attribute_map = { + 'monitoring_status': {'key': 'monitoringStatus', 'type': 'str'}, + } + + def __init__( + self, + *, + monitoring_status: Optional[Union[str, "MonitoringStatus"]] = None, + **kwargs + ): + super(MonitorUpdateProperties, self).__init__(**kwargs) + self.monitoring_status = monitoring_status + + +class OperationDisplay(msrest.serialization.Model): + """The object that represents the operation. + + :param provider: Service provider, i.e., Microsoft.Logz. + :type provider: str + :param resource: Type on which the operation is performed, e.g., 'monitors'. + :type resource: str + :param operation: Operation type, e.g., read, write, delete, etc. + :type operation: str + :param description: Description of the operation, e.g., 'Write monitors'. + :type description: str + """ + + _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, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationListResult(msrest.serialization.Model): + """Result of GET request to list the Microsoft.Logz operations. + + :param value: List of operations supported by the Microsoft.Logz provider. + :type value: list[~microsoft_logz.models.OperationResult] + :param next_link: URL to get the next set of operation list results if there are any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[OperationResult]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["OperationResult"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class OperationResult(msrest.serialization.Model): + """A Microsoft.Logz REST API operation. + + :param name: Operation name, i.e., {provider}/{resource}/{operation}. + :type name: str + :param is_data_action: Indicates whether the operation is a data action. + :type is_data_action: bool + :param display: The object that represents the operation. + :type display: ~microsoft_logz.models.OperationDisplay + :param origin: Origin of the operation. + :type origin: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + is_data_action: Optional[bool] = None, + display: Optional["OperationDisplay"] = None, + origin: Optional[str] = None, + **kwargs + ): + super(OperationResult, self).__init__(**kwargs) + self.name = name + self.is_data_action = is_data_action + self.display = display + self.origin = origin + + +class PlanData(msrest.serialization.Model): + """PlanData. + + :param usage_type: different usage type like PAYG/COMMITTED. this could be enum. + :type usage_type: str + :param billing_cycle: different billing cycles like MONTHLY/WEEKLY. this could be enum. + :type billing_cycle: str + :param plan_details: plan id as published by Logz. + :type plan_details: str + :param effective_date: date when plan was applied. + :type effective_date: ~datetime.datetime + """ + + _validation = { + 'usage_type': {'max_length': 50, 'min_length': 0}, + 'billing_cycle': {'max_length': 50, 'min_length': 0}, + 'plan_details': {'max_length': 50, 'min_length': 0}, + } + + _attribute_map = { + 'usage_type': {'key': 'usageType', 'type': 'str'}, + 'billing_cycle': {'key': 'billingCycle', 'type': 'str'}, + 'plan_details': {'key': 'planDetails', 'type': 'str'}, + 'effective_date': {'key': 'effectiveDate', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + usage_type: Optional[str] = None, + billing_cycle: Optional[str] = None, + plan_details: Optional[str] = None, + effective_date: Optional[datetime.datetime] = None, + **kwargs + ): + super(PlanData, self).__init__(**kwargs) + self.usage_type = usage_type + self.billing_cycle = billing_cycle + self.plan_details = plan_details + self.effective_date = effective_date + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :type created_by_type: str or ~microsoft_logz.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: ~datetime.datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :type last_modified_by_type: str or ~microsoft_logz.models.CreatedByType + :param last_modified_at: The timestamp of resource last modification (UTC). + :type 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, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + super(SystemData, self).__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 UserInfo(msrest.serialization.Model): + """UserInfo. + + :param first_name: First Name of the user. + :type first_name: str + :param last_name: Last Name of the user. + :type last_name: str + :param email_address: Email of the user used by Logz for contacting them if needed. + :type email_address: str + :param phone_number: Phone number of the user used by Logz for contacting them if needed. + :type phone_number: str + """ + + _validation = { + 'first_name': {'max_length': 50, 'min_length': 0}, + 'last_name': {'max_length': 50, 'min_length': 0}, + 'email_address': {'pattern': r'^[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,}$'}, + 'phone_number': {'max_length': 40, 'min_length': 0}, + } + + _attribute_map = { + 'first_name': {'key': 'firstName', 'type': 'str'}, + 'last_name': {'key': 'lastName', 'type': 'str'}, + 'email_address': {'key': 'emailAddress', 'type': 'str'}, + 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + } + + def __init__( + self, + *, + first_name: Optional[str] = None, + last_name: Optional[str] = None, + email_address: Optional[str] = None, + phone_number: Optional[str] = None, + **kwargs + ): + super(UserInfo, self).__init__(**kwargs) + self.first_name = first_name + self.last_name = last_name + self.email_address = email_address + self.phone_number = phone_number + + +class UserRoleListResponse(msrest.serialization.Model): + """Response for list of user's role for Logz.io account. + + :param value: List of user roles for Logz.io account. + :type value: list[~microsoft_logz.models.UserRoleResponse] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[UserRoleResponse]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["UserRoleResponse"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(UserRoleListResponse, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class UserRoleRequest(msrest.serialization.Model): + """Request for checking user's role for Logz.io account. + + :param email_address: Email of the user used by Logz for contacting them if needed. + :type email_address: str + """ + + _validation = { + 'email_address': {'pattern': r'^[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,}$'}, + } + + _attribute_map = { + 'email_address': {'key': 'emailAddress', 'type': 'str'}, + } + + def __init__( + self, + *, + email_address: Optional[str] = None, + **kwargs + ): + super(UserRoleRequest, self).__init__(**kwargs) + self.email_address = email_address + + +class UserRoleResponse(msrest.serialization.Model): + """Response for checking user's role for Logz.io account. + + :param role: User roles on configured in Logz.io account. Possible values include: "None", + "User", "Admin". + :type role: str or ~microsoft_logz.models.UserRole + """ + + _attribute_map = { + 'role': {'key': 'role', 'type': 'str'}, + } + + def __init__( + self, + *, + role: Optional[Union[str, "UserRole"]] = None, + **kwargs + ): + super(UserRoleResponse, self).__init__(**kwargs) + self.role = role + + +class VMExtensionPayload(msrest.serialization.Model): + """Response of payload to be passed while installing VM agent. + + :param api_key: API Key corresponding to the resource. + :type api_key: str + :param region: Logz.io region where the resource has been created. + :type region: str + """ + + _attribute_map = { + 'api_key': {'key': 'apiKey', 'type': 'str'}, + 'region': {'key': 'region', 'type': 'str'}, + } + + def __init__( + self, + *, + api_key: Optional[str] = None, + region: Optional[str] = None, + **kwargs + ): + super(VMExtensionPayload, self).__init__(**kwargs) + self.api_key = api_key + self.region = region + + +class VMHostUpdateRequest(msrest.serialization.Model): + """Request of a list VM Host Update Operation. + + :param vm_resource_ids: Request of a list vm host update operation. + :type vm_resource_ids: list[~microsoft_logz.models.VMResources] + :param state: Specifies the state of the operation - install/ delete. Possible values include: + "Install", "Delete". + :type state: str or ~microsoft_logz.models.VMHostUpdateStates + """ + + _attribute_map = { + 'vm_resource_ids': {'key': 'vmResourceIds', 'type': '[VMResources]'}, + 'state': {'key': 'state', 'type': 'str'}, + } + + def __init__( + self, + *, + vm_resource_ids: Optional[List["VMResources"]] = None, + state: Optional[Union[str, "VMHostUpdateStates"]] = None, + **kwargs + ): + super(VMHostUpdateRequest, self).__init__(**kwargs) + self.vm_resource_ids = vm_resource_ids + self.state = state + + +class VMResources(msrest.serialization.Model): + """VM Resource Ids. + + :param id: Request of a list vm host update operation. + :type id: str + :param agent_version: Version of the Logz agent installed on the VM. + :type agent_version: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'agent_version': {'key': 'agentVersion', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + agent_version: Optional[str] = None, + **kwargs + ): + super(VMResources, self).__init__(**kwargs) + self.id = id + self.agent_version = agent_version + + +class VMResourcesListResponse(msrest.serialization.Model): + """Response of a list VM Host Update Operation. + + :param value: Response of a list vm host update operation. + :type value: list[~microsoft_logz.models.VMResources] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[VMResources]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["VMResources"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(VMResourcesListResponse, self).__init__(**kwargs) + self.value = value + self.next_link = next_link diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/__init__.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/__init__.py new file mode 100644 index 000000000000..9c8560a389dc --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/__init__.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._monitors_operations import MonitorsOperations +from ._operations import Operations +from ._tag_rules_operations import TagRulesOperations +from ._single_sign_on_operations import SingleSignOnOperations +from ._sub_account_operations import SubAccountOperations +from ._sub_account_tag_rules_operations import SubAccountTagRulesOperations +from ._monitor_operations import MonitorOperations + +__all__ = [ + 'MonitorsOperations', + 'Operations', + 'TagRulesOperations', + 'SingleSignOnOperations', + 'SubAccountOperations', + 'SubAccountTagRulesOperations', + 'MonitorOperations', +] diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_monitor_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_monitor_operations.py new file mode 100644 index 000000000000..979a1a49305f --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_monitor_operations.py @@ -0,0 +1,283 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +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 as _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 MonitorOperations(object): + """MonitorOperations 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: ~microsoft_logz.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 vm_host_payload( + self, + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.VMExtensionPayload" + """Returns the payload that needs to be passed in the request body for installing Logz.io agent on a VM. + + Returns the payload that needs to be passed in the request body for installing Logz.io agent on + a VM. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VMExtensionPayload, or the result of cls(response) + :rtype: ~microsoft_logz.models.VMExtensionPayload + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMExtensionPayload"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.vm_host_payload.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('VMExtensionPayload', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + vm_host_payload.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/vmHostPayload'} # type: ignore + + def list_vm_host_update( + self, + resource_group_name, # type: str + monitor_name, # type: str + body=None, # type: Optional["_models.VMHostUpdateRequest"] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.VMResourcesListResponse"] + """Sending request to update the collection when Logz.io agent has been installed on a VM for a given monitor. + + Sending request to update the collection when Logz.io agent has been installed on a VM for a + given monitor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param body: Request body to update the collection for agent installed in the given monitor. + :type body: ~microsoft_logz.models.VMHostUpdateRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either VMResourcesListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.VMResourcesListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMResourcesListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = "application/json" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_vm_host_update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'VMHostUpdateRequest') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'VMHostUpdateRequest') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('VMResourcesListResponse', 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.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) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_vm_host_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/vmHostUpdate'} # type: ignore + + def list_vm_hosts( + self, + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.VMResourcesListResponse"] + """List the compute resources currently being monitored by the Logz main account resource. + + List the compute resources currently being monitored by the Logz main account resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either VMResourcesListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.VMResourcesListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMResourcesListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-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_vm_hosts.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + request = self._client.post(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('VMResourcesListResponse', 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.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) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_vm_hosts.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/listVMHosts'} # type: ignore diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_monitors_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_monitors_operations.py new file mode 100644 index 000000000000..494b17261233 --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_monitors_operations.py @@ -0,0 +1,754 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +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.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + 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: ~microsoft_logz.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_monitored_resources( + self, + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.MonitoredResourceListResponse"] + """List the resources currently being monitored by the Logz monitor resource. + + List the resources currently being monitored by the Logz monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MonitoredResourceListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.MonitoredResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoredResourceListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-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_monitored_resources.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + request = self._client.post(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('MonitoredResourceListResponse', 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.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) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_monitored_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/listMonitoredResources'} # type: ignore + + def list_by_subscription( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.LogzMonitorResourceListResponse"] + """List all monitors under the specified subscription. + + List all monitors under 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 LogzMonitorResourceListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.LogzMonitorResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResourceListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-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_by_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + 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') + + 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('LogzMonitorResourceListResponse', 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.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) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Logz/monitors'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.LogzMonitorResourceListResponse"] + """List all monitors under the specified resource group. + + List all monitors under the specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :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 LogzMonitorResourceListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.LogzMonitorResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResourceListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-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_by_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + 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') + + 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('LogzMonitorResourceListResponse', 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.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) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors'} # type: ignore + + def get( + self, + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.LogzMonitorResource" + """Get the properties of a specific monitor resource. + + Get the properties of a specific monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogzMonitorResource, or the result of cls(response) + :rtype: ~microsoft_logz.models.LogzMonitorResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + # 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LogzMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}'} # type: ignore + + def _create_initial( + self, + resource_group_name, # type: str + monitor_name, # type: str + body=None, # type: Optional["_models.LogzMonitorResource"] + **kwargs # type: Any + ): + # type: (...) -> "_models.LogzMonitorResource" + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'LogzMonitorResource') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('LogzMonitorResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('LogzMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}'} # type: ignore + + def begin_create( + self, + resource_group_name, # type: str + monitor_name, # type: str + body=None, # type: Optional["_models.LogzMonitorResource"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.LogzMonitorResource"] + """Create a monitor resource. + + Create a monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param body: + :type body: ~microsoft_logz.models.LogzMonitorResource + :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 LogzMonitorResource or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~microsoft_logz.models.LogzMonitorResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('LogzMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}'} # type: ignore + + def update( + self, + resource_group_name, # type: str + monitor_name, # type: str + body=None, # type: Optional["_models.LogzMonitorResourceUpdateParameters"] + **kwargs # type: Any + ): + # type: (...) -> "_models.LogzMonitorResource" + """Update a monitor resource. + + Update a monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param body: + :type body: ~microsoft_logz.models.LogzMonitorResourceUpdateParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogzMonitorResource, or the result of cls(response) + :rtype: ~microsoft_logz.models.LogzMonitorResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'LogzMonitorResourceUpdateParameters') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LogzMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}'} # type: ignore + + def _delete_initial( + self, + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(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, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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')) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Delete a monitor resource. + + Delete a monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}'} # type: ignore + + def list_user_roles( + self, + resource_group_name, # type: str + monitor_name, # type: str + body=None, # type: Optional["_models.UserRoleRequest"] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.UserRoleListResponse"] + """List the user's roles configured on Logz.io side for the account corresponding to the monitor resource. + + List the user's roles configured on Logz.io side for the account corresponding to the monitor + resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param body: + :type body: ~microsoft_logz.models.UserRoleRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either UserRoleListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.UserRoleListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.UserRoleListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = "application/json" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_user_roles.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'UserRoleRequest') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'UserRoleRequest') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('UserRoleListResponse', 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.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) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_user_roles.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/listUserRoles'} # type: ignore diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_operations.py new file mode 100644 index 000000000000..f277b281438a --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_operations.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. +# -------------------------------------------------------------------------- +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 as _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 Operations(object): + """Operations 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: ~microsoft_logz.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, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.OperationListResult"] + """List all operations provided by Microsoft.Logz. + + List all operations provided by Microsoft.Logz. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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 + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + 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('OperationListResult', 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.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) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Logz/operations'} # type: ignore diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_single_sign_on_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_single_sign_on_operations.py new file mode 100644 index 000000000000..96e2b5600cdb --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_single_sign_on_operations.py @@ -0,0 +1,335 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +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.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class SingleSignOnOperations(object): + """SingleSignOnOperations 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: ~microsoft_logz.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, + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.LogzSingleSignOnResourceListResponse"] + """List the single sign-on configurations for a given monitor resource. + + List the single sign-on configurations for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LogzSingleSignOnResourceListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.LogzSingleSignOnResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzSingleSignOnResourceListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-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("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + 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('LogzSingleSignOnResourceListResponse', 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.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) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/singleSignOnConfigurations'} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name, # type: str + monitor_name, # type: str + configuration_name, # type: str + body=None, # type: Optional["_models.LogzSingleSignOnResource"] + **kwargs # type: Any + ): + # type: (...) -> "_models.LogzSingleSignOnResource" + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzSingleSignOnResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'configurationName': self._serialize.url("configuration_name", configuration_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'LogzSingleSignOnResource') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('LogzSingleSignOnResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('LogzSingleSignOnResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + monitor_name, # type: str + configuration_name, # type: str + body=None, # type: Optional["_models.LogzSingleSignOnResource"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.LogzSingleSignOnResource"] + """Configures single-sign-on for this resource. + + Configures single-sign-on for this resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param configuration_name: + :type configuration_name: str + :param body: + :type body: ~microsoft_logz.models.LogzSingleSignOnResource + :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 LogzSingleSignOnResource or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~microsoft_logz.models.LogzSingleSignOnResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzSingleSignOnResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + configuration_name=configuration_name, + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('LogzSingleSignOnResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}'} # type: ignore + + def get( + self, + resource_group_name, # type: str + monitor_name, # type: str + configuration_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.LogzSingleSignOnResource" + """Gets the Logz single sign-on resource for the given Monitor. + + Gets the Logz single sign-on resource for the given Monitor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param configuration_name: + :type configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogzSingleSignOnResource, or the result of cls(response) + :rtype: ~microsoft_logz.models.LogzSingleSignOnResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzSingleSignOnResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'configurationName': self._serialize.url("configuration_name", configuration_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') + + # 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LogzSingleSignOnResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}'} # type: ignore diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_sub_account_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_sub_account_operations.py new file mode 100644 index 000000000000..652db099ee7b --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_sub_account_operations.py @@ -0,0 +1,866 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +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.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class SubAccountOperations(object): + """SubAccountOperations 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: ~microsoft_logz.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, + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.LogzMonitorResourceListResponse"] + """List the sub account under a given monitor resource. + + List the sub account under a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LogzMonitorResourceListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.LogzMonitorResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResourceListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-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("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + 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('LogzMonitorResourceListResponse', 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.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) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts'} # type: ignore + + def _create_initial( + self, + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + body=None, # type: Optional["_models.LogzMonitorResource"] + **kwargs # type: Any + ): + # type: (...) -> "_models.LogzMonitorResource" + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'LogzMonitorResource') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('LogzMonitorResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('LogzMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + + def begin_create( + self, + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + body=None, # type: Optional["_models.LogzMonitorResource"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.LogzMonitorResource"] + """Create sub account under a given monitor resource. + + Create sub account under a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_name: str + :param body: + :type body: ~microsoft_logz.models.LogzMonitorResource + :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 LogzMonitorResource or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~microsoft_logz.models.LogzMonitorResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('LogzMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + + def get( + self, + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.LogzMonitorResource" + """Get a sub account under a given monitor resource. + + Get a sub account under a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogzMonitorResource, or the result of cls(response) + :rtype: ~microsoft_logz.models.LogzMonitorResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_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') + + # 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LogzMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + + def _delete_initial( + self, + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(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, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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')) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Delete a sub account resource. + + Delete a sub account resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + + def update( + self, + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + body=None, # type: Optional["_models.LogzMonitorResourceUpdateParameters"] + **kwargs # type: Any + ): + # type: (...) -> "_models.LogzMonitorResource" + """Update a monitor resource. + + Update a monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_name: str + :param body: + :type body: ~microsoft_logz.models.LogzMonitorResourceUpdateParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogzMonitorResource, or the result of cls(response) + :rtype: ~microsoft_logz.models.LogzMonitorResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'LogzMonitorResourceUpdateParameters') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LogzMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + + def list_monitored_resources( + self, + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.MonitoredResourceListResponse"] + """List the resources currently being monitored by the Logz sub account resource. + + List the resources currently being monitored by the Logz sub account resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MonitoredResourceListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.MonitoredResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoredResourceListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-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_monitored_resources.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_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') + + request = self._client.post(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('MonitoredResourceListResponse', 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.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) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_monitored_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/listMonitoredResources'} # type: ignore + + def vm_host_payload( + self, + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.VMExtensionPayload" + """Returns the payload that needs to be passed as a request for installing Logz.io agent on a VM. + + Returns the payload that needs to be passed as a request for installing Logz.io agent on a VM. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VMExtensionPayload, or the result of cls(response) + :rtype: ~microsoft_logz.models.VMExtensionPayload + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMExtensionPayload"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.vm_host_payload.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('VMExtensionPayload', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + vm_host_payload.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/vmHostPayload'} # type: ignore + + def list_vm_host_update( + self, + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + body=None, # type: Optional["_models.VMHostUpdateRequest"] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.VMResourcesListResponse"] + """Sending request to update the collection when Logz.io agent has been installed on a VM for a given monitor. + + Sending request to update the collection when Logz.io agent has been installed on a VM for a + given monitor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_name: str + :param body: Request body to update the collection for agent installed in the given monitor. + :type body: ~microsoft_logz.models.VMHostUpdateRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either VMResourcesListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.VMResourcesListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMResourcesListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = "application/json" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_vm_host_update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_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') + + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'VMHostUpdateRequest') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'VMHostUpdateRequest') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('VMResourcesListResponse', 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.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) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_vm_host_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/vmHostUpdate'} # type: ignore + + def list_vm_hosts( + self, + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.VMResourcesListResponse"] + """List the compute resources currently being monitored by the Logz sub account resource. + + List the compute resources currently being monitored by the Logz sub account resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either VMResourcesListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.VMResourcesListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMResourcesListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-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_vm_hosts.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_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') + + request = self._client.post(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('VMResourcesListResponse', 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.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) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_vm_hosts.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/listVMHosts'} # type: ignore diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_sub_account_tag_rules_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_sub_account_tag_rules_operations.py new file mode 100644 index 000000000000..4a59bc484f54 --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_sub_account_tag_rules_operations.py @@ -0,0 +1,350 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +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 as _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 SubAccountTagRulesOperations(object): + """SubAccountTagRulesOperations 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: ~microsoft_logz.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, + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.MonitoringTagRulesListResponse"] + """List the tag rules for a given sub account resource. + + List the tag rules for a given sub account resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MonitoringTagRulesListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.MonitoringTagRulesListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringTagRulesListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-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("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_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') + + 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('MonitoringTagRulesListResponse', 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.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) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/tagRules'} # type: ignore + + def create_or_update( + self, + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + rule_set_name, # type: str + body=None, # type: Optional["_models.MonitoringTagRules"] + **kwargs # type: Any + ): + # type: (...) -> "_models.MonitoringTagRules" + """Create or update a tag rule set for a given sub account resource. + + Create or update a tag rule set for a given sub account resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_name: str + :param rule_set_name: + :type rule_set_name: str + :param body: + :type body: ~microsoft_logz.models.MonitoringTagRules + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MonitoringTagRules, or the result of cls(response) + :rtype: ~microsoft_logz.models.MonitoringTagRules + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringTagRules"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), + 'ruleSetName': self._serialize.url("rule_set_name", rule_set_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'MonitoringTagRules') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('MonitoringTagRules', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/tagRules/{ruleSetName}'} # type: ignore + + def get( + self, + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + rule_set_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.MonitoringTagRules" + """Get a tag rule set for a given monitor resource. + + Get a tag rule set for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_name: str + :param rule_set_name: + :type rule_set_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MonitoringTagRules, or the result of cls(response) + :rtype: ~microsoft_logz.models.MonitoringTagRules + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringTagRules"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), + 'ruleSetName': self._serialize.url("rule_set_name", rule_set_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') + + # 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('MonitoringTagRules', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/tagRules/{ruleSetName}'} # type: ignore + + def delete( + self, + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + rule_set_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Delete a tag rule set for a given monitor resource. + + Delete a tag rule set for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param sub_account_name: Sub Account resource name. + :type sub_account_name: str + :param rule_set_name: + :type rule_set_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 + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), + 'ruleSetName': self._serialize.url("rule_set_name", rule_set_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(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, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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')) + + if cls: + return cls(pipeline_response, None, response_headers) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/tagRules/{ruleSetName}'} # type: ignore diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_tag_rules_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_tag_rules_operations.py new file mode 100644 index 000000000000..20d60b0e9907 --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_tag_rules_operations.py @@ -0,0 +1,334 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +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 as _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 TagRulesOperations(object): + """TagRulesOperations 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: ~microsoft_logz.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, + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.MonitoringTagRulesListResponse"] + """List the tag rules for a given monitor resource. + + List the tag rules for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MonitoringTagRulesListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.MonitoringTagRulesListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringTagRulesListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-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("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_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') + + 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('MonitoringTagRulesListResponse', 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.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) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/tagRules'} # type: ignore + + def create_or_update( + self, + resource_group_name, # type: str + monitor_name, # type: str + rule_set_name, # type: str + body=None, # type: Optional["_models.MonitoringTagRules"] + **kwargs # type: Any + ): + # type: (...) -> "_models.MonitoringTagRules" + """Create or update a tag rule set for a given monitor resource. + + Create or update a tag rule set for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param rule_set_name: + :type rule_set_name: str + :param body: + :type body: ~microsoft_logz.models.MonitoringTagRules + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MonitoringTagRules, or the result of cls(response) + :rtype: ~microsoft_logz.models.MonitoringTagRules + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringTagRules"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'ruleSetName': self._serialize.url("rule_set_name", rule_set_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if body is not None: + body_content = self._serialize.body(body, 'MonitoringTagRules') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('MonitoringTagRules', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/tagRules/{ruleSetName}'} # type: ignore + + def get( + self, + resource_group_name, # type: str + monitor_name, # type: str + rule_set_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.MonitoringTagRules" + """Get a tag rule set for a given monitor resource. + + Get a tag rule set for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param rule_set_name: + :type rule_set_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MonitoringTagRules, or the result of cls(response) + :rtype: ~microsoft_logz.models.MonitoringTagRules + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringTagRules"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'ruleSetName': self._serialize.url("rule_set_name", rule_set_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') + + # 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('MonitoringTagRules', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/tagRules/{ruleSetName}'} # type: ignore + + def delete( + self, + resource_group_name, # type: str + monitor_name, # type: str + rule_set_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Delete a tag rule set for a given monitor resource. + + Delete a tag rule set for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param rule_set_name: + :type rule_set_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 + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'ruleSetName': self._serialize.url("rule_set_name", rule_set_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(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, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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')) + + if cls: + return cls(pipeline_response, None, response_headers) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/tagRules/{ruleSetName}'} # type: ignore diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/py.typed b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/logz/azure-mgmt-logz/sdk_packaging.toml b/sdk/logz/azure-mgmt-logz/sdk_packaging.toml new file mode 100644 index 000000000000..fdcc08f69dce --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +package_name = "azure-mgmt-logz" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "MyService Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true diff --git a/sdk/logz/azure-mgmt-logz/setup.cfg b/sdk/logz/azure-mgmt-logz/setup.cfg new file mode 100644 index 000000000000..3c6e79cf31da --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/sdk/logz/azure-mgmt-logz/setup.py b/sdk/logz/azure-mgmt-logz/setup.py new file mode 100644 index 000000000000..1a7957264f99 --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/setup.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import re +import os.path +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-mgmt-logz" +PACKAGE_PPRINT_NAME = "MyService Management" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# azure v0.x is not compatible with this package +# azure v0.x used to have a __version__ attribute (newer versions don't) +try: + import azure + try: + ver = azure.__version__ + raise Exception( + 'This package is incompatible with azure=={}. '.format(ver) + + 'Uninstall it with "pip uninstall azure".' + ) + except AttributeError: + pass +except ImportError: + pass + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, 'version.py') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else os.path.join(package_folder_path, '_version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.md', encoding='utf-8') as f: + readme = f.read() +with open('CHANGELOG.md', encoding='utf-8') as f: + changelog = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + changelog, + long_description_content_type='text/markdown', + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + 'azure.mgmt', + ]), + install_requires=[ + 'msrest>=0.6.21', + 'azure-common~=1.1', + 'azure-mgmt-core>=1.2.0,<2.0.0', + ], + extras_require={ + ":python_version<'3.0'": ['azure-mgmt-nspkg'], + } +) diff --git a/sdk/logz/ci.yml b/sdk/logz/ci.yml new file mode 100644 index 000000000000..99622feda59b --- /dev/null +++ b/sdk/logz/ci.yml @@ -0,0 +1,35 @@ +# DO NOT EDIT THIS FILE +# This file is generated automatically and any changes will be lost. + +trigger: + branches: + include: + - master + - main + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/logz/ + +pr: + branches: + include: + - master + - main + - feature/* + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/logz/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: logz + Artifacts: + - name: azure-mgmt-logz + safeName: azuremgmtlogz From 4ec4dd139c77b3142817e04a1a0dffbe101f5439 Mon Sep 17 00:00:00 2001 From: PythonSdkPipelines Date: Wed, 2 Jun 2021 05:55:15 +0000 Subject: [PATCH 2/2] version,CHANGELOG --- sdk/logz/azure-mgmt-logz/CHANGELOG.md | 2 +- sdk/logz/azure-mgmt-logz/README.md | 4 ++-- sdk/logz/azure-mgmt-logz/sdk_packaging.toml | 2 +- sdk/logz/azure-mgmt-logz/setup.py | 2 +- shared_requirements.txt | 1 + 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sdk/logz/azure-mgmt-logz/CHANGELOG.md b/sdk/logz/azure-mgmt-logz/CHANGELOG.md index 578ed6acf479..38915b2ad996 100644 --- a/sdk/logz/azure-mgmt-logz/CHANGELOG.md +++ b/sdk/logz/azure-mgmt-logz/CHANGELOG.md @@ -1,5 +1,5 @@ # Release History -## 0.1.0 (1970-01-01) +## 1.0.0b1 (2021-06-02) * Initial Release diff --git a/sdk/logz/azure-mgmt-logz/README.md b/sdk/logz/azure-mgmt-logz/README.md index 2d9056532bae..a0b2439151de 100644 --- a/sdk/logz/azure-mgmt-logz/README.md +++ b/sdk/logz/azure-mgmt-logz/README.md @@ -1,6 +1,6 @@ # Microsoft Azure SDK for Python -This is the Microsoft Azure MyService Management Client Library. +This is the Microsoft Azure Logz Management Client Library. This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). @@ -13,7 +13,7 @@ To learn how to use this package, see the [quickstart guide](https://aka.ms/azsd For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) -Code samples for this package can be found at [MyService Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. +Code samples for this package can be found at [Logz Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) diff --git a/sdk/logz/azure-mgmt-logz/sdk_packaging.toml b/sdk/logz/azure-mgmt-logz/sdk_packaging.toml index fdcc08f69dce..9c725e62a984 100644 --- a/sdk/logz/azure-mgmt-logz/sdk_packaging.toml +++ b/sdk/logz/azure-mgmt-logz/sdk_packaging.toml @@ -1,7 +1,7 @@ [packaging] package_name = "azure-mgmt-logz" package_nspkg = "azure-mgmt-nspkg" -package_pprint_name = "MyService Management" +package_pprint_name = "Logz Management" package_doc_id = "" is_stable = false is_arm = true diff --git a/sdk/logz/azure-mgmt-logz/setup.py b/sdk/logz/azure-mgmt-logz/setup.py index 1a7957264f99..7ef2cf5fb11b 100644 --- a/sdk/logz/azure-mgmt-logz/setup.py +++ b/sdk/logz/azure-mgmt-logz/setup.py @@ -13,7 +13,7 @@ # Change the PACKAGE_NAME only to change folder and different name PACKAGE_NAME = "azure-mgmt-logz" -PACKAGE_PPRINT_NAME = "MyService Management" +PACKAGE_PPRINT_NAME = "Logz Management" # a-b-c => a/b/c package_folder_path = PACKAGE_NAME.replace('-', '/') diff --git a/shared_requirements.txt b/shared_requirements.txt index e52239bf4878..361c3f8e05e9 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -289,3 +289,4 @@ opentelemetry-sdk<2.0.0,>=1.0.0 #override azure-mgmt-agfood msrest>=0.6.21 #override azure-mgmt-sqlvirtualmachine msrest>=0.6.21 #override azure-mgmt-msi msrest>=0.6.21 +#override azure-mgmt-logz msrest>=0.6.21