From 20cf00dacb16de347062fdaaa0f078fd2ac455cf Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 1 Jul 2022 07:02:43 +0000 Subject: [PATCH] CodeGen from PR 19416 in Azure/azure-rest-api-specs [OperationalInsights] workspace and component purge (#19416) * Add blockchain to latest profile * Add additional types * Purge update * bad syntax fix for workspacePurge examples * pretty Co-authored-by: Mark Cowlishaw --- .../azure-mgmt-loganalytics/_meta.json | 6 +- .../azure/mgmt/loganalytics/__init__.py | 13 +- .../azure/mgmt/loganalytics/_configuration.py | 2 +- .../_log_analytics_management_client.py | 99 +++- .../azure/mgmt/loganalytics/_metadata.json | 123 ----- .../azure/mgmt/loganalytics/_version.py | 2 +- .../azure/mgmt/loganalytics/aio/__init__.py | 13 +- .../mgmt/loganalytics/aio/_configuration.py | 2 +- .../aio/_log_analytics_management_client.py | 97 +++- .../loganalytics/aio/operations/__init__.py | 5 + .../_available_service_tiers_operations.py | 61 ++- .../aio/operations/_clusters_operations.py | 310 ++++++++---- .../operations/_data_exports_operations.py | 150 ++++-- .../operations/_data_sources_operations.py | 153 ++++-- .../_deleted_workspaces_operations.py | 99 ++-- .../aio/operations/_gateways_operations.py | 61 ++- .../_intelligence_packs_operations.py | 115 +++-- .../operations/_linked_services_operations.py | 216 +++++--- .../_linked_storage_accounts_operations.py | 150 ++++-- .../_management_groups_operations.py | 67 ++- .../_operation_statuses_operations.py | 61 ++- .../aio/operations/_operations.py | 67 ++- .../loganalytics/aio/operations/_patch.py | 19 + .../aio/operations/_queries_operations.py | 223 ++++++--- .../aio/operations/_query_packs_operations.py | 212 +++++--- .../operations/_saved_searches_operations.py | 145 ++++-- .../aio/operations/_schema_operations.py | 61 ++- .../aio/operations/_shared_keys_operations.py | 88 ++-- .../_storage_insight_configs_operations.py | 150 ++++-- .../aio/operations/_tables_operations.py | 305 ++++++++---- .../aio/operations/_usages_operations.py | 67 ++- .../operations/_workspace_purge_operations.py | 94 ++-- .../aio/operations/_workspaces_operations.py | 277 ++++++++--- .../mgmt/loganalytics/models/__init__.py | 6 +- .../_log_analytics_management_client_enums.py | 54 +- .../mgmt/loganalytics/models/_models_py3.py | 324 ++++++------ .../azure/mgmt/loganalytics/models/_patch.py | 19 + .../mgmt/loganalytics/operations/__init__.py | 5 + .../_available_service_tiers_operations.py | 90 ++-- .../operations/_clusters_operations.py | 470 +++++++++++------- .../operations/_data_exports_operations.py | 257 ++++++---- .../operations/_data_sources_operations.py | 255 ++++++---- .../_deleted_workspaces_operations.py | 151 +++--- .../operations/_gateways_operations.py | 81 +-- .../_intelligence_packs_operations.py | 174 ++++--- .../operations/_linked_services_operations.py | 323 +++++++----- .../_linked_storage_accounts_operations.py | 248 +++++---- .../_management_groups_operations.py | 95 ++-- .../_operation_statuses_operations.py | 90 ++-- .../loganalytics/operations/_operations.py | 93 ++-- .../mgmt/loganalytics/operations/_patch.py | 19 + .../operations/_queries_operations.py | 400 +++++++++------ .../operations/_query_packs_operations.py | 372 +++++++++----- .../operations/_saved_searches_operations.py | 243 +++++---- .../operations/_schema_operations.py | 90 ++-- .../operations/_shared_keys_operations.py | 141 ++++-- .../_storage_insight_configs_operations.py | 248 +++++---- .../operations/_tables_operations.py | 465 ++++++++++------- .../operations/_usages_operations.py | 95 ++-- .../operations/_workspace_purge_operations.py | 153 +++--- .../operations/_workspaces_operations.py | 439 ++++++++++------ 61 files changed, 5701 insertions(+), 3212 deletions(-) delete mode 100644 sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_metadata.json create mode 100644 sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_patch.py create mode 100644 sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_patch.py create mode 100644 sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_patch.py diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/_meta.json b/sdk/loganalytics/azure-mgmt-loganalytics/_meta.json index 99175fd7fcf6..5bd6744b0ff5 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/_meta.json +++ b/sdk/loganalytics/azure-mgmt-loganalytics/_meta.json @@ -1,11 +1,11 @@ { "autorest": "3.7.2", "use": [ - "@autorest/python@5.12.0", + "@autorest/python@5.16.0", "@autorest/modelerfour@4.19.3" ], - "commit": "b52f90085693d0ec65f751e30c65c3a878c340ea", + "commit": "1ddabd9234338d209f9755beac5c13cc0ae3b5f7", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/operationalinsights/resource-manager/readme.md --multiapi --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/operationalinsights/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/operationalinsights/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/__init__.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/__init__.py index a957d1d31663..1a69e17d15a2 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/__init__.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['LogAnalyticsManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_configuration.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_configuration.py index 085bd8a4b4f5..39a74b846654 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_configuration.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class LogAnalyticsManagementClientConfiguration(Configuration): +class LogAnalyticsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for LogAnalyticsManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_log_analytics_management_client.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_log_analytics_management_client.py index fc8c3e8d04a4..f9f71472ad2e 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_log_analytics_management_client.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_log_analytics_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import LogAnalyticsManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class LogAnalyticsManagementClient: +class LogAnalyticsManagementClient: # pylint: disable=too-many-instance-attributes """Operational Insights Client. :ivar query_packs: QueryPacksOperations operations @@ -75,7 +76,7 @@ class LogAnalyticsManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -95,33 +96,77 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.query_packs = QueryPacksOperations(self._client, self._config, self._serialize, self._deserialize) - self.queries = QueriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_exports = DataExportsOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_sources = DataSourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.intelligence_packs = IntelligencePacksOperations(self._client, self._config, self._serialize, self._deserialize) - self.linked_services = LinkedServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.linked_storage_accounts = LinkedStorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_groups = ManagementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_statuses = OperationStatusesOperations(self._client, self._config, self._serialize, self._deserialize) - self.shared_keys = SharedKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_insight_configs = StorageInsightConfigsOperations(self._client, self._config, self._serialize, self._deserialize) - self.saved_searches = SavedSearchesOperations(self._client, self._config, self._serialize, self._deserialize) - self.available_service_tiers = AvailableServiceTiersOperations(self._client, self._config, self._serialize, self._deserialize) - self.gateways = GatewaysOperations(self._client, self._config, self._serialize, self._deserialize) - self.schema = SchemaOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_purge = WorkspacePurgeOperations(self._client, self._config, self._serialize, self._deserialize) - self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.workspaces = WorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) - self.deleted_workspaces = DeletedWorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) - self.tables = TablesOperations(self._client, self._config, self._serialize, self._deserialize) + self.query_packs = QueryPacksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queries = QueriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.data_exports = DataExportsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.data_sources = DataSourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.intelligence_packs = IntelligencePacksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.linked_services = LinkedServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.linked_storage_accounts = LinkedStorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_groups = ManagementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operation_statuses = OperationStatusesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_keys = SharedKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_insight_configs = StorageInsightConfigsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.saved_searches = SavedSearchesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.available_service_tiers = AvailableServiceTiersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gateways = GatewaysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.schema = SchemaOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_purge = WorkspacePurgeOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.clusters = ClustersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspaces = WorkspacesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_workspaces = DeletedWorkspacesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.tables = TablesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_metadata.json b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_metadata.json deleted file mode 100644 index 0d6a20f7de89..000000000000 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_metadata.json +++ /dev/null @@ -1,123 +0,0 @@ -{ - "chosen_version": "", - "total_api_version_list": ["2019-09-01", "2020-08-01", "2021-06-01", "2021-12-01-preview"], - "client": { - "name": "LogAnalyticsManagementClient", - "filename": "_log_analytics_management_client", - "description": "Operational Insights Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": 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\": [\"LogAnalyticsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"LogAnalyticsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" - }, - "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=\"https://management.azure.com\", # type: 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: str = \"https://management.azure.com\",", - "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_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "query_packs": "QueryPacksOperations", - "queries": "QueriesOperations", - "data_exports": "DataExportsOperations", - "data_sources": "DataSourcesOperations", - "intelligence_packs": "IntelligencePacksOperations", - "linked_services": "LinkedServicesOperations", - "linked_storage_accounts": "LinkedStorageAccountsOperations", - "management_groups": "ManagementGroupsOperations", - "operation_statuses": "OperationStatusesOperations", - "shared_keys": "SharedKeysOperations", - "usages": "UsagesOperations", - "storage_insight_configs": "StorageInsightConfigsOperations", - "saved_searches": "SavedSearchesOperations", - "available_service_tiers": "AvailableServiceTiersOperations", - "gateways": "GatewaysOperations", - "schema": "SchemaOperations", - "workspace_purge": "WorkspacePurgeOperations", - "clusters": "ClustersOperations", - "operations": "Operations", - "workspaces": "WorkspacesOperations", - "deleted_workspaces": "DeletedWorkspacesOperations", - "tables": "TablesOperations" - } -} \ No newline at end of file diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_version.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_version.py index 018e7f36e942..efe7276fe05f 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_version.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "13.0.0b4" +VERSION = "7.0.0b1" diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/__init__.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/__init__.py index 0db0687689d3..8d0126e7f914 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/__init__.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._log_analytics_management_client import LogAnalyticsManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['LogAnalyticsManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/_configuration.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/_configuration.py index 2d5f005522d1..4f258f01de1d 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/_configuration.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class LogAnalyticsManagementClientConfiguration(Configuration): +class LogAnalyticsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for LogAnalyticsManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/_log_analytics_management_client.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/_log_analytics_management_client.py index d0bea923329e..277c84ccc9ba 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/_log_analytics_management_client.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/_log_analytics_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import LogAnalyticsManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class LogAnalyticsManagementClient: +class LogAnalyticsManagementClient: # pylint: disable=too-many-instance-attributes """Operational Insights Client. :ivar query_packs: QueryPacksOperations operations @@ -75,7 +76,7 @@ class LogAnalyticsManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -95,28 +96,72 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.query_packs = QueryPacksOperations(self._client, self._config, self._serialize, self._deserialize) - self.queries = QueriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_exports = DataExportsOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_sources = DataSourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.intelligence_packs = IntelligencePacksOperations(self._client, self._config, self._serialize, self._deserialize) - self.linked_services = LinkedServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.linked_storage_accounts = LinkedStorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_groups = ManagementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_statuses = OperationStatusesOperations(self._client, self._config, self._serialize, self._deserialize) - self.shared_keys = SharedKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_insight_configs = StorageInsightConfigsOperations(self._client, self._config, self._serialize, self._deserialize) - self.saved_searches = SavedSearchesOperations(self._client, self._config, self._serialize, self._deserialize) - self.available_service_tiers = AvailableServiceTiersOperations(self._client, self._config, self._serialize, self._deserialize) - self.gateways = GatewaysOperations(self._client, self._config, self._serialize, self._deserialize) - self.schema = SchemaOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_purge = WorkspacePurgeOperations(self._client, self._config, self._serialize, self._deserialize) - self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.workspaces = WorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) - self.deleted_workspaces = DeletedWorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) - self.tables = TablesOperations(self._client, self._config, self._serialize, self._deserialize) + self.query_packs = QueryPacksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queries = QueriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.data_exports = DataExportsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.data_sources = DataSourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.intelligence_packs = IntelligencePacksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.linked_services = LinkedServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.linked_storage_accounts = LinkedStorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_groups = ManagementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operation_statuses = OperationStatusesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_keys = SharedKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_insight_configs = StorageInsightConfigsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.saved_searches = SavedSearchesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.available_service_tiers = AvailableServiceTiersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gateways = GatewaysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.schema = SchemaOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_purge = WorkspacePurgeOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.clusters = ClustersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspaces = WorkspacesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_workspaces = DeletedWorkspacesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.tables = TablesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/__init__.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/__init__.py index 72e307c7d6e6..09f82c9f74e2 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/__init__.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/__init__.py @@ -29,6 +29,9 @@ from ._deleted_workspaces_operations import DeletedWorkspacesOperations from ._tables_operations import TablesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'QueryPacksOperations', 'QueriesOperations', @@ -53,3 +56,5 @@ 'DeletedWorkspacesOperations', 'TablesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_available_service_tiers_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_available_service_tiers_operations.py index 66ee66610067..1d7cccfc9d0e 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_available_service_tiers_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_available_service_tiers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, List, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AvailableServiceTiersOperations: - """AvailableServiceTiersOperations 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.aio.LogAnalyticsManagementClient`'s + :attr:`available_service_tiers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list_by_workspace( @@ -50,35 +48,50 @@ async def list_by_workspace( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> List["_models.AvailableServiceTier"]: + ) -> List[_models.AvailableServiceTier]: """Gets the available service tiers for the workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: list of AvailableServiceTier, or the result of cls(response) :rtype: list[~azure.mgmt.loganalytics.models.AvailableServiceTier] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.AvailableServiceTier"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.AvailableServiceTier]] request = build_list_by_workspace_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + api_version=api_version, template_url=self.list_by_workspace.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,5 +105,5 @@ async def list_by_workspace( return deserialized - list_by_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/availableServiceTiers'} # type: ignore + list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/availableServiceTiers"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_clusters_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_clusters_operations.py index 24d73944b912..dbe602d781a5 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_clusters_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_clusters_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -27,68 +27,80 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ClustersOperations: - """ClustersOperations 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.aio.LogAnalyticsManagementClient`'s + :attr:`clusters` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ClusterListResult"]: + ) -> AsyncIterable[_models.ClusterListResult]: """Gets Log Analytics clusters in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str + :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ClusterListResult or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.loganalytics.models.ClusterListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ClusterListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -102,7 +114,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -116,44 +132,58 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ClusterListResult"]: + ) -> AsyncIterable[_models.ClusterListResult]: """Gets the Log Analytics clusters in a subscription. + :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ClusterListResult or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.loganalytics.models.ClusterListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ClusterListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -167,7 +197,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,22 +215,26 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/clusters'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/clusters"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, - parameters: "_models.Cluster", + parameters: _models.Cluster, **kwargs: Any - ) -> Optional["_models.Cluster"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Cluster"]] + ) -> Optional[_models.Cluster]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Cluster]] _json = self._serialize.body(parameters, 'Cluster') @@ -204,14 +242,21 @@ async def _create_or_update_initial( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, cluster_name=cluster_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -230,7 +275,7 @@ async def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}"} # type: ignore @distributed_trace_async @@ -238,9 +283,9 @@ async def begin_create_or_update( self, resource_group_name: str, cluster_name: str, - parameters: "_models.Cluster", + parameters: _models.Cluster, **kwargs: Any - ) -> AsyncLROPoller["_models.Cluster"]: + ) -> AsyncLROPoller[_models.Cluster]: """Create or update a Log Analytics cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -249,6 +294,9 @@ async def begin_create_or_update( :type cluster_name: str :param parameters: The parameters required to create or update a Log Analytics cluster. :type parameters: ~azure.mgmt.loganalytics.models.Cluster + :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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 @@ -262,35 +310,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.loganalytics.models.Cluster] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Cluster] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 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( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('Cluster', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -299,34 +359,45 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}"} # type: ignore - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -336,11 +407,11 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}"} # type: ignore @distributed_trace_async - async def begin_delete( + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, @@ -352,6 +423,9 @@ async def begin_delete( :type resource_group_name: str :param cluster_name: Name of the Log Analytics Cluster. :type cluster_name: str + :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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 @@ -364,18 +438,25 @@ async def begin_delete( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 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( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -385,8 +466,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -395,10 +482,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}"} # type: ignore @distributed_trace_async async def get( @@ -406,35 +492,50 @@ async def get( resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> "_models.Cluster": + ) -> _models.Cluster: """Gets a Log Analytics cluster instance. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param cluster_name: Name of the Log Analytics Cluster. :type cluster_name: str + :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Cluster, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.Cluster :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Cluster] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -449,23 +550,27 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}"} # type: ignore async def _update_initial( self, resource_group_name: str, cluster_name: str, - parameters: "_models.ClusterPatch", + parameters: _models.ClusterPatch, **kwargs: Any - ) -> "_models.Cluster": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] + ) -> _models.Cluster: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Cluster] _json = self._serialize.body(parameters, 'ClusterPatch') @@ -473,14 +578,21 @@ async def _update_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -494,7 +606,7 @@ async def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}"} # type: ignore @distributed_trace_async @@ -502,9 +614,9 @@ async def begin_update( self, resource_group_name: str, cluster_name: str, - parameters: "_models.ClusterPatch", + parameters: _models.ClusterPatch, **kwargs: Any - ) -> AsyncLROPoller["_models.Cluster"]: + ) -> AsyncLROPoller[_models.Cluster]: """Updates a Log Analytics cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -513,6 +625,9 @@ async def begin_update( :type cluster_name: str :param parameters: The parameters required to patch a Log Analytics cluster. :type parameters: ~azure.mgmt.loganalytics.models.ClusterPatch + :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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 @@ -526,35 +641,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.loganalytics.models.Cluster] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Cluster] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 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._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('Cluster', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -563,7 +690,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_data_exports_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_data_exports_operations.py index 1d9126b36f51..2f28e093c9da 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_data_exports_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_data_exports_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DataExportsOperations: - """DataExportsOperations 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.aio.LogAnalyticsManagementClient`'s + :attr:`data_exports` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_workspace( @@ -52,13 +50,16 @@ def list_by_workspace( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataExportListResult"]: + ) -> AsyncIterable[_models.DataExportListResult]: """Lists the data export instances within a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DataExportListResult or the result of cls(response) @@ -66,11 +67,16 @@ def list_by_workspace( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.loganalytics.models.DataExportListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataExportListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataExportListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -78,10 +84,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + api_version=api_version, template_url=self.list_by_workspace.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -89,10 +98,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -106,7 +118,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -120,7 +136,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports'} # type: ignore + list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports"} # type: ignore @distributed_trace_async async def create_or_update( @@ -128,9 +144,9 @@ async def create_or_update( resource_group_name: str, workspace_name: str, data_export_name: str, - parameters: "_models.DataExport", + parameters: _models.DataExport, **kwargs: Any - ) -> "_models.DataExport": + ) -> _models.DataExport: """Create or update a data export. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -141,18 +157,25 @@ async def create_or_update( :type data_export_name: str :param parameters: The parameters required to create or update a data export. :type parameters: ~azure.mgmt.loganalytics.models.DataExport + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DataExport, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.DataExport :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataExport"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataExport] _json = self._serialize.body(parameters, 'DataExport') @@ -161,14 +184,21 @@ async def create_or_update( resource_group_name=resource_group_name, workspace_name=workspace_name, data_export_name=data_export_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -187,7 +217,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports/{dataExportName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports/{dataExportName}"} # type: ignore @distributed_trace_async @@ -197,7 +227,7 @@ async def get( workspace_name: str, data_export_name: str, **kwargs: Any - ) -> "_models.DataExport": + ) -> _models.DataExport: """Gets a data export instance. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -206,16 +236,24 @@ async def get( :type workspace_name: str :param data_export_name: The data export rule name. :type data_export_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DataExport, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.DataExport :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataExport"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataExport] request = build_get_request( @@ -223,12 +261,19 @@ async def get( resource_group_name=resource_group_name, workspace_name=workspace_name, data_export_name=data_export_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -243,11 +288,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports/{dataExportName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports/{dataExportName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, @@ -262,16 +307,24 @@ async def delete( :type workspace_name: str :param data_export_name: The data export rule name. :type data_export_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -279,12 +332,19 @@ async def delete( resource_group_name=resource_group_name, workspace_name=workspace_name, data_export_name=data_export_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 404]: @@ -295,5 +355,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports/{dataExportName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports/{dataExportName}"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_data_sources_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_data_sources_operations.py index ec28b9132fe3..d4e66306885d 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_data_sources_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_data_sources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DataSourcesOperations: - """DataSourcesOperations 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.aio.LogAnalyticsManagementClient`'s + :attr:`data_sources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create_or_update( @@ -52,9 +50,9 @@ async def create_or_update( resource_group_name: str, workspace_name: str, data_source_name: str, - parameters: "_models.DataSource", + parameters: _models.DataSource, **kwargs: Any - ) -> "_models.DataSource": + ) -> _models.DataSource: """Create or update a data source. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -65,18 +63,25 @@ async def create_or_update( :type data_source_name: str :param parameters: The parameters required to create or update a datasource. :type parameters: ~azure.mgmt.loganalytics.models.DataSource + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DataSource, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.DataSource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataSource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataSource] _json = self._serialize.body(parameters, 'DataSource') @@ -85,14 +90,21 @@ async def create_or_update( workspace_name=workspace_name, data_source_name=data_source_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -110,11 +122,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources/{dataSourceName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources/{dataSourceName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, @@ -129,16 +141,24 @@ async def delete( :type workspace_name: str :param data_source_name: Name of the datasource. :type data_source_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -146,12 +166,19 @@ async def delete( workspace_name=workspace_name, data_source_name=data_source_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -161,7 +188,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources/{dataSourceName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources/{dataSourceName}"} # type: ignore @distributed_trace_async @@ -171,7 +198,7 @@ async def get( workspace_name: str, data_source_name: str, **kwargs: Any - ) -> "_models.DataSource": + ) -> _models.DataSource: """Gets a datasource instance. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -180,16 +207,24 @@ async def get( :type workspace_name: str :param data_source_name: Name of the datasource. :type data_source_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DataSource, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.DataSource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataSource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataSource] request = build_get_request( @@ -197,12 +232,19 @@ async def get( workspace_name=workspace_name, data_source_name=data_source_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -216,7 +258,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources/{dataSourceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources/{dataSourceName}"} # type: ignore @distributed_trace @@ -227,7 +269,7 @@ def list_by_workspace( filter: str, skiptoken: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.DataSourceListResult"]: + ) -> AsyncIterable[_models.DataSourceListResult]: """Gets the first page of data source instances in a workspace with the link to the next page. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -236,8 +278,12 @@ def list_by_workspace( :type workspace_name: str :param filter: The filter to apply on the operation. :type filter: str - :param skiptoken: Starting point of the collection of data source instances. + :param skiptoken: Starting point of the collection of data source instances. Default value is + None. :type skiptoken: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DataSourceListResult or the result of cls(response) @@ -245,11 +291,16 @@ def list_by_workspace( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.loganalytics.models.DataSourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataSourceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataSourceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -257,12 +308,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, skiptoken=skiptoken, template_url=self.list_by_workspace.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -270,12 +324,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, skiptoken=skiptoken, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -289,7 +346,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -302,4 +363,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources'} # type: ignore + list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_deleted_workspaces_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_deleted_workspaces_operations.py index 10cc88fe71c5..82ef00b59101 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_deleted_workspaces_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_deleted_workspaces_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,63 +24,75 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DeletedWorkspacesOperations: - """DeletedWorkspacesOperations 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.aio.LogAnalyticsManagementClient`'s + :attr:`deleted_workspaces` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.WorkspaceListResult"]: + ) -> AsyncIterable[_models.WorkspaceListResult]: """Gets recently deleted workspaces in a subscription, available for recovery. + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkspaceListResult or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.loganalytics.models.WorkspaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspaceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,7 +106,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,49 +124,63 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/deletedWorkspaces'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/deletedWorkspaces"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.WorkspaceListResult"]: + ) -> AsyncIterable[_models.WorkspaceListResult]: """Gets recently deleted workspaces in a resource group, available for recovery. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkspaceListResult or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.loganalytics.models.WorkspaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspaceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -165,7 +194,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -179,4 +212,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/deletedWorkspaces'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/deletedWorkspaces"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_gateways_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_gateways_operations.py index a95ab84604cc..0414a08121f6 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_gateways_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_gateways_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,29 +23,27 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GatewaysOperations: - """GatewaysOperations 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.aio.LogAnalyticsManagementClient`'s + :attr:`gateways` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, @@ -60,16 +58,24 @@ async def delete( :type workspace_name: str :param gateway_id: The Log Analytics gateway Id. :type gateway_id: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -77,12 +83,19 @@ async def delete( resource_group_name=resource_group_name, workspace_name=workspace_name, gateway_id=gateway_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,5 +105,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/gateways/{gatewayId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/gateways/{gatewayId}"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_intelligence_packs_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_intelligence_packs_operations.py index 72c9a0aee83c..19a951f37a64 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_intelligence_packs_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_intelligence_packs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, List, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,29 +23,27 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class IntelligencePacksOperations: - """IntelligencePacksOperations 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.aio.LogAnalyticsManagementClient`'s + :attr:`intelligence_packs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async - async def disable( + async def disable( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, @@ -60,16 +58,24 @@ async def disable( :type workspace_name: str :param intelligence_pack_name: The name of the intelligence pack to be disabled. :type intelligence_pack_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_disable_request( @@ -77,12 +83,19 @@ async def disable( workspace_name=workspace_name, intelligence_pack_name=intelligence_pack_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.disable.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,11 +105,11 @@ async def disable( if cls: return cls(pipeline_response, None, {}) - disable.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/intelligencePacks/{intelligencePackName}/Disable'} # type: ignore + disable.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/intelligencePacks/{intelligencePackName}/Disable"} # type: ignore @distributed_trace_async - async def enable( + async def enable( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, @@ -111,16 +124,24 @@ async def enable( :type workspace_name: str :param intelligence_pack_name: The name of the intelligence pack to be enabled. :type intelligence_pack_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_enable_request( @@ -128,12 +149,19 @@ async def enable( workspace_name=workspace_name, intelligence_pack_name=intelligence_pack_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.enable.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -143,7 +171,7 @@ async def enable( if cls: return cls(pipeline_response, None, {}) - enable.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/intelligencePacks/{intelligencePackName}/Enable'} # type: ignore + enable.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/intelligencePacks/{intelligencePackName}/Enable"} # type: ignore @distributed_trace_async @@ -152,7 +180,7 @@ async def list( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> List["_models.IntelligencePack"]: + ) -> List[_models.IntelligencePack]: """Lists all the intelligence packs possible and whether they are enabled or disabled for a given workspace. @@ -160,28 +188,43 @@ async def list( :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: list of IntelligencePack, or the result of cls(response) :rtype: list[~azure.mgmt.loganalytics.models.IntelligencePack] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.IntelligencePack"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.IntelligencePack]] request = build_list_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -195,5 +238,5 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/intelligencePacks'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/intelligencePacks"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_linked_services_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_linked_services_operations.py index f0c89c5ac63b..ef788b872dd7 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_linked_services_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_linked_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -27,42 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LinkedServicesOperations: - """LinkedServicesOperations 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.aio.LogAnalyticsManagementClient`'s + :attr:`linked_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, linked_service_name: str, - parameters: "_models.LinkedService", + parameters: _models.LinkedService, **kwargs: Any - ) -> Optional["_models.LinkedService"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LinkedService"]] + ) -> Optional[_models.LinkedService]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.LinkedService]] _json = self._serialize.body(parameters, 'LinkedService') @@ -71,14 +73,21 @@ async def _create_or_update_initial( workspace_name=workspace_name, linked_service_name=linked_service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -97,7 +106,7 @@ async def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}"} # type: ignore @distributed_trace_async @@ -106,9 +115,9 @@ async def begin_create_or_update( resource_group_name: str, workspace_name: str, linked_service_name: str, - parameters: "_models.LinkedService", + parameters: _models.LinkedService, **kwargs: Any - ) -> AsyncLROPoller["_models.LinkedService"]: + ) -> AsyncLROPoller[_models.LinkedService]: """Create or update a linked service. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -119,6 +128,9 @@ async def begin_create_or_update( :type linked_service_name: str :param parameters: The parameters required to create or update a linked service. :type parameters: ~azure.mgmt.loganalytics.models.LinkedService + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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 @@ -132,36 +144,48 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.loganalytics.models.LinkedService] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkedService"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LinkedService] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 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( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, linked_service_name=linked_service_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('LinkedService', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -170,10 +194,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}"} # type: ignore async def _delete_initial( self, @@ -181,12 +204,17 @@ async def _delete_initial( workspace_name: str, linked_service_name: str, **kwargs: Any - ) -> Optional["_models.LinkedService"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LinkedService"]] + ) -> Optional[_models.LinkedService]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.LinkedService]] request = build_delete_request_initial( @@ -194,12 +222,19 @@ async def _delete_initial( workspace_name=workspace_name, linked_service_name=linked_service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -215,7 +250,7 @@ async def _delete_initial( return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}"} # type: ignore @distributed_trace_async @@ -225,7 +260,7 @@ async def begin_delete( workspace_name: str, linked_service_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.LinkedService"]: + ) -> AsyncLROPoller[_models.LinkedService]: """Deletes a linked service instance. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -234,6 +269,9 @@ async def begin_delete( :type workspace_name: str :param linked_service_name: Name of the linked service. :type linked_service_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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 @@ -247,33 +285,45 @@ async def begin_delete( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.loganalytics.models.LinkedService] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkedService"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LinkedService] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 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( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, linked_service_name=linked_service_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('LinkedService', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -282,10 +332,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}"} # type: ignore @distributed_trace_async async def get( @@ -294,7 +343,7 @@ async def get( workspace_name: str, linked_service_name: str, **kwargs: Any - ) -> "_models.LinkedService": + ) -> _models.LinkedService: """Gets a linked service instance. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -303,16 +352,24 @@ async def get( :type workspace_name: str :param linked_service_name: Name of the linked service. :type linked_service_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LinkedService, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.LinkedService :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkedService"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LinkedService] request = build_get_request( @@ -320,12 +377,19 @@ async def get( workspace_name=workspace_name, linked_service_name=linked_service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -339,7 +403,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}"} # type: ignore @distributed_trace @@ -348,13 +412,16 @@ def list_by_workspace( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> AsyncIterable["_models.LinkedServiceListResult"]: + ) -> AsyncIterable[_models.LinkedServiceListResult]: """Gets the linked services instances in a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LinkedServiceListResult or the result of cls(response) @@ -362,11 +429,16 @@ def list_by_workspace( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.loganalytics.models.LinkedServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkedServiceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LinkedServiceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -374,10 +446,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_workspace.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -385,10 +460,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -402,7 +480,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -415,4 +497,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices'} # type: ignore + list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_linked_storage_accounts_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_linked_storage_accounts_operations.py index 8979093c138c..aa7c8019168d 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_linked_storage_accounts_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_linked_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LinkedStorageAccountsOperations: - """LinkedStorageAccountsOperations 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.aio.LogAnalyticsManagementClient`'s + :attr:`linked_storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create_or_update( @@ -52,9 +50,9 @@ async def create_or_update( resource_group_name: str, workspace_name: str, data_source_type: Union[str, "_models.DataSourceType"], - parameters: "_models.LinkedStorageAccountsResource", + parameters: _models.LinkedStorageAccountsResource, **kwargs: Any - ) -> "_models.LinkedStorageAccountsResource": + ) -> _models.LinkedStorageAccountsResource: """Create or Update a link relation between current workspace and a group of storage accounts of a specific data source type. @@ -66,18 +64,25 @@ async def create_or_update( :type data_source_type: str or ~azure.mgmt.loganalytics.models.DataSourceType :param parameters: The parameters required to create or update linked storage accounts. :type parameters: ~azure.mgmt.loganalytics.models.LinkedStorageAccountsResource + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LinkedStorageAccountsResource, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.LinkedStorageAccountsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkedStorageAccountsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LinkedStorageAccountsResource] _json = self._serialize.body(parameters, 'LinkedStorageAccountsResource') @@ -86,14 +91,21 @@ async def create_or_update( workspace_name=workspace_name, data_source_type=data_source_type, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -107,11 +119,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts/{dataSourceType}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts/{dataSourceType}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, @@ -127,16 +139,24 @@ async def delete( :type workspace_name: str :param data_source_type: Linked storage accounts type. :type data_source_type: str or ~azure.mgmt.loganalytics.models.DataSourceType + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -144,12 +164,19 @@ async def delete( workspace_name=workspace_name, data_source_type=data_source_type, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,7 +186,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts/{dataSourceType}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts/{dataSourceType}"} # type: ignore @distributed_trace_async @@ -169,7 +196,7 @@ async def get( workspace_name: str, data_source_type: Union[str, "_models.DataSourceType"], **kwargs: Any - ) -> "_models.LinkedStorageAccountsResource": + ) -> _models.LinkedStorageAccountsResource: """Gets all linked storage account of a specific data source type associated with the specified workspace. @@ -179,16 +206,24 @@ async def get( :type workspace_name: str :param data_source_type: Linked storage accounts type. :type data_source_type: str or ~azure.mgmt.loganalytics.models.DataSourceType + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LinkedStorageAccountsResource, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.LinkedStorageAccountsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkedStorageAccountsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LinkedStorageAccountsResource] request = build_get_request( @@ -196,12 +231,19 @@ async def get( workspace_name=workspace_name, data_source_type=data_source_type, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -215,7 +257,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts/{dataSourceType}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts/{dataSourceType}"} # type: ignore @distributed_trace @@ -224,7 +266,7 @@ def list_by_workspace( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> AsyncIterable["_models.LinkedStorageAccountsListResult"]: + ) -> AsyncIterable[_models.LinkedStorageAccountsListResult]: """Gets all linked storage accounts associated with the specified workspace, storage accounts will be sorted by their data source type. @@ -232,6 +274,9 @@ def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LinkedStorageAccountsListResult or the result of cls(response) @@ -239,11 +284,16 @@ def list_by_workspace( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.loganalytics.models.LinkedStorageAccountsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkedStorageAccountsListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LinkedStorageAccountsListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -251,10 +301,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + api_version=api_version, template_url=self.list_by_workspace.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -262,10 +315,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -279,7 +335,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -292,4 +352,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts'} # type: ignore + list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_management_groups_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_management_groups_operations.py index 456a87f940a4..e8c5a2788741 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_management_groups_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_management_groups_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,26 +24,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ManagementGroupsOperations: - """ManagementGroupsOperations 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.aio.LogAnalyticsManagementClient`'s + :attr:`management_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,13 +49,16 @@ def list( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> AsyncIterable["_models.WorkspaceListManagementGroupsResult"]: + ) -> AsyncIterable[_models.WorkspaceListManagementGroupsResult]: """Gets a list of management groups connected to a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkspaceListManagementGroupsResult or the result of cls(response) @@ -66,11 +66,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.loganalytics.models.WorkspaceListManagementGroupsResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceListManagementGroupsResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspaceListManagementGroupsResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -78,10 +83,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -89,10 +97,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -106,7 +117,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,4 +134,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/managementGroups'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/managementGroups"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_operation_statuses_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_operation_statuses_operations.py index a4f76742d1ac..77323c92adc5 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_operation_statuses_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_operation_statuses_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class OperationStatusesOperations: - """OperationStatusesOperations 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.aio.LogAnalyticsManagementClient`'s + :attr:`operation_statuses` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -50,35 +48,50 @@ async def get( location: str, async_operation_id: str, **kwargs: Any - ) -> "_models.OperationStatus": + ) -> _models.OperationStatus: """Get the status of a long running azure asynchronous operation. :param location: The region name of operation. :type location: str :param async_operation_id: The operation Id. :type async_operation_id: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationStatus, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.OperationStatus :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatus"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatus] request = build_get_request( location=location, async_operation_id=async_operation_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,5 +105,5 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/locations/{location}/operationStatuses/{asyncOperationId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/locations/{location}/operationStatuses/{asyncOperationId}"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_operations.py index 9de052029e93..342378d50988 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,61 +24,73 @@ 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.aio.LogAnalyticsManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """Lists all of the available OperationalInsights Rest API operations. + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :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[~azure.mgmt.loganalytics.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +104,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -107,4 +122,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.OperationalInsights/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.OperationalInsights/operations"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_patch.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_queries_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_queries_operations.py index 03ebb04d26ed..c4dc8b5784af 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_queries_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_queries_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class QueriesOperations: - """QueriesOperations 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.aio.LogAnalyticsManagementClient`'s + :attr:`queries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -55,20 +53,23 @@ def list( include_body: Optional[bool] = None, skip_token: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.LogAnalyticsQueryPackQueryListResult"]: + ) -> AsyncIterable[_models.LogAnalyticsQueryPackQueryListResult]: """Gets a list of Queries defined within a Log Analytics QueryPack. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param query_pack_name: The name of the Log Analytics QueryPack resource. :type query_pack_name: str - :param top: Maximum items returned in page. + :param top: Maximum items returned in page. Default value is None. :type top: long :param include_body: Flag indicating whether or not to return the body of each applicable - query. If false, only return the query information. + query. If false, only return the query information. Default value is None. :type include_body: bool :param skip_token: Base64 encoded token used to fetch the next page of items. Default is null. :type skip_token: str + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LogAnalyticsQueryPackQueryListResult or the result of cls(response) @@ -76,11 +77,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQueryListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackQueryListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsQueryPackQueryListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -88,13 +94,16 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, query_pack_name=query_pack_name, + api_version=api_version, top=top, include_body=include_body, skip_token=skip_token, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -102,13 +111,16 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, query_pack_name=query_pack_name, + api_version=api_version, top=top, include_body=include_body, skip_token=skip_token, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -122,7 +134,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -136,19 +152,19 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries"} # type: ignore @distributed_trace def search( self, resource_group_name: str, query_pack_name: str, - query_search_properties: "_models.LogAnalyticsQueryPackQuerySearchProperties", + query_search_properties: _models.LogAnalyticsQueryPackQuerySearchProperties, top: Optional[int] = None, include_body: Optional[bool] = None, skip_token: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.LogAnalyticsQueryPackQueryListResult"]: + ) -> AsyncIterable[_models.LogAnalyticsQueryPackQueryListResult]: """Search a list of Queries defined within a Log Analytics QueryPack according to given search properties. @@ -160,13 +176,16 @@ def search( Analytics QueryPack. :type query_search_properties: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuerySearchProperties - :param top: Maximum items returned in page. + :param top: Maximum items returned in page. Default value is None. :type top: long :param include_body: Flag indicating whether or not to return the body of each applicable - query. If false, only return the query information. + query. If false, only return the query information. Default value is None. :type include_body: bool :param skip_token: Base64 encoded token used to fetch the next page of items. Default is null. :type skip_token: str + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LogAnalyticsQueryPackQueryListResult or the result of cls(response) @@ -174,13 +193,17 @@ def search( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQueryListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsQueryPackQueryListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackQueryListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: _json = self._serialize.body(query_search_properties, 'LogAnalyticsQueryPackQuerySearchProperties') @@ -189,15 +212,18 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, query_pack_name=query_pack_name, + api_version=api_version, content_type=content_type, json=_json, top=top, include_body=include_body, skip_token=skip_token, template_url=self.search.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: _json = self._serialize.body(query_search_properties, 'LogAnalyticsQueryPackQuerySearchProperties') @@ -206,15 +232,18 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, query_pack_name=query_pack_name, + api_version=api_version, content_type=content_type, json=_json, top=top, include_body=include_body, skip_token=skip_token, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -228,7 +257,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -242,7 +275,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - search.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/search'} # type: ignore + search.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/search"} # type: ignore @distributed_trace_async async def get( @@ -251,7 +284,7 @@ async def get( query_pack_name: str, id: str, **kwargs: Any - ) -> "_models.LogAnalyticsQueryPackQuery": + ) -> _models.LogAnalyticsQueryPackQuery: """Gets a specific Log Analytics Query defined within a Log Analytics QueryPack. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -260,16 +293,24 @@ async def get( :type query_pack_name: str :param id: The id of a specific query defined in the Log Analytics QueryPack. :type id: str + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LogAnalyticsQueryPackQuery, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackQuery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsQueryPackQuery] request = build_get_request( @@ -277,12 +318,19 @@ async def get( resource_group_name=resource_group_name, query_pack_name=query_pack_name, id=id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -297,7 +345,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}"} # type: ignore @distributed_trace_async @@ -306,9 +354,9 @@ async def put( resource_group_name: str, query_pack_name: str, id: str, - query_payload: "_models.LogAnalyticsQueryPackQuery", + query_payload: _models.LogAnalyticsQueryPackQuery, **kwargs: Any - ) -> "_models.LogAnalyticsQueryPackQuery": + ) -> _models.LogAnalyticsQueryPackQuery: """Adds or Updates a specific Query within a Log Analytics QueryPack. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -320,18 +368,25 @@ async def put( :param query_payload: Properties that need to be specified to create a new query and add it to a Log Analytics QueryPack. :type query_payload: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuery + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LogAnalyticsQueryPackQuery, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackQuery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsQueryPackQuery] _json = self._serialize.body(query_payload, 'LogAnalyticsQueryPackQuery') @@ -340,14 +395,21 @@ async def put( resource_group_name=resource_group_name, query_pack_name=query_pack_name, id=id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -362,7 +424,7 @@ async def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}"} # type: ignore @distributed_trace_async @@ -371,9 +433,9 @@ async def update( resource_group_name: str, query_pack_name: str, id: str, - query_payload: "_models.LogAnalyticsQueryPackQuery", + query_payload: _models.LogAnalyticsQueryPackQuery, **kwargs: Any - ) -> "_models.LogAnalyticsQueryPackQuery": + ) -> _models.LogAnalyticsQueryPackQuery: """Adds or Updates a specific Query within a Log Analytics QueryPack. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -385,18 +447,25 @@ async def update( :param query_payload: Properties that need to be specified to create a new query and add it to a Log Analytics QueryPack. :type query_payload: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuery + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LogAnalyticsQueryPackQuery, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackQuery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsQueryPackQuery] _json = self._serialize.body(query_payload, 'LogAnalyticsQueryPackQuery') @@ -405,14 +474,21 @@ async def update( resource_group_name=resource_group_name, query_pack_name=query_pack_name, id=id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -427,11 +503,11 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, query_pack_name: str, @@ -446,16 +522,24 @@ async def delete( :type query_pack_name: str :param id: The id of a specific query defined in the Log Analytics QueryPack. :type id: str + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -463,12 +547,19 @@ async def delete( resource_group_name=resource_group_name, query_pack_name=query_pack_name, id=id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -479,5 +570,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_query_packs_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_query_packs_operations.py index ebc1d0be1bcb..8ba1f9b9feb4 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_query_packs_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_query_packs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,34 +25,35 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class QueryPacksOperations: - """QueryPacksOperations 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.aio.LogAnalyticsManagementClient`'s + :attr:`query_packs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.LogAnalyticsQueryPackListResult"]: + ) -> AsyncIterable[_models.LogAnalyticsQueryPackListResult]: """Gets a list of all Log Analytics QueryPacks within a subscription. + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LogAnalyticsQueryPackListResult or the result of cls(response) @@ -60,29 +61,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsQueryPackListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +108,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,18 +126,21 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/queryPacks'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/queryPacks"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.LogAnalyticsQueryPackListResult"]: + ) -> AsyncIterable[_models.LogAnalyticsQueryPackListResult]: """Gets a list of Log Analytics QueryPacks within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LogAnalyticsQueryPackListResult or the result of cls(response) @@ -129,31 +148,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsQueryPackListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -167,7 +197,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,10 +215,10 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, query_pack_name: str, @@ -196,28 +230,43 @@ async def delete( :type resource_group_name: str :param query_pack_name: The name of the Log Analytics QueryPack resource. :type query_pack_name: str + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, query_pack_name=query_pack_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -228,7 +277,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}"} # type: ignore @distributed_trace_async @@ -237,35 +286,50 @@ async def get( resource_group_name: str, query_pack_name: str, **kwargs: Any - ) -> "_models.LogAnalyticsQueryPack": + ) -> _models.LogAnalyticsQueryPack: """Returns a Log Analytics QueryPack. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param query_pack_name: The name of the Log Analytics QueryPack resource. :type query_pack_name: str + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LogAnalyticsQueryPack, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPack :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPack"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsQueryPack] request = build_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, query_pack_name=query_pack_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +344,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}"} # type: ignore @distributed_trace_async @@ -288,9 +352,9 @@ async def create_or_update( self, resource_group_name: str, query_pack_name: str, - log_analytics_query_pack_payload: "_models.LogAnalyticsQueryPack", + log_analytics_query_pack_payload: _models.LogAnalyticsQueryPack, **kwargs: Any - ) -> "_models.LogAnalyticsQueryPack": + ) -> _models.LogAnalyticsQueryPack: """Creates (or updates) a Log Analytics QueryPack. Note: You cannot specify a different value for InstrumentationKey nor AppId in the Put operation. @@ -301,18 +365,25 @@ async def create_or_update( :param log_analytics_query_pack_payload: Properties that need to be specified to create or update a Log Analytics QueryPack. :type log_analytics_query_pack_payload: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPack + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LogAnalyticsQueryPack, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPack :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPack"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsQueryPack] _json = self._serialize.body(log_analytics_query_pack_payload, 'LogAnalyticsQueryPack') @@ -320,14 +391,21 @@ async def create_or_update( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, query_pack_name=query_pack_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -342,7 +420,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}"} # type: ignore @distributed_trace_async @@ -350,9 +428,9 @@ async def update_tags( self, resource_group_name: str, query_pack_name: str, - query_pack_tags: "_models.TagsResource", + query_pack_tags: _models.TagsResource, **kwargs: Any - ) -> "_models.LogAnalyticsQueryPack": + ) -> _models.LogAnalyticsQueryPack: """Updates an existing QueryPack's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -361,18 +439,25 @@ async def update_tags( :type query_pack_name: str :param query_pack_tags: Updated tag information to set into the QueryPack instance. :type query_pack_tags: ~azure.mgmt.loganalytics.models.TagsResource + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LogAnalyticsQueryPack, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPack :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPack"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsQueryPack] _json = self._serialize.body(query_pack_tags, 'TagsResource') @@ -380,14 +465,21 @@ async def update_tags( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, query_pack_name=query_pack_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update_tags.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -402,5 +494,5 @@ async def update_tags( return deserialized - update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}'} # type: ignore + update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_saved_searches_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_saved_searches_operations.py index cd2cc0dc5a37..0e9777b3bff9 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_saved_searches_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_saved_searches_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,29 +23,27 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SavedSearchesOperations: - """SavedSearchesOperations 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.aio.LogAnalyticsManagementClient`'s + :attr:`saved_searches` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, @@ -60,16 +58,24 @@ async def delete( :type workspace_name: str :param saved_search_id: The id of the saved search. :type saved_search_id: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -77,12 +83,19 @@ async def delete( resource_group_name=resource_group_name, workspace_name=workspace_name, saved_search_id=saved_search_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,7 +105,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches/{savedSearchId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches/{savedSearchId}"} # type: ignore @distributed_trace_async @@ -101,9 +114,9 @@ async def create_or_update( resource_group_name: str, workspace_name: str, saved_search_id: str, - parameters: "_models.SavedSearch", + parameters: _models.SavedSearch, **kwargs: Any - ) -> "_models.SavedSearch": + ) -> _models.SavedSearch: """Creates or updates a saved search for a given workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -114,18 +127,25 @@ async def create_or_update( :type saved_search_id: str :param parameters: The parameters required to save a search. :type parameters: ~azure.mgmt.loganalytics.models.SavedSearch + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SavedSearch, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.SavedSearch :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SavedSearch"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SavedSearch] _json = self._serialize.body(parameters, 'SavedSearch') @@ -134,14 +154,21 @@ async def create_or_update( resource_group_name=resource_group_name, workspace_name=workspace_name, saved_search_id=saved_search_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -155,7 +182,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches/{savedSearchId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches/{savedSearchId}"} # type: ignore @distributed_trace_async @@ -165,7 +192,7 @@ async def get( workspace_name: str, saved_search_id: str, **kwargs: Any - ) -> "_models.SavedSearch": + ) -> _models.SavedSearch: """Gets the specified saved search for a given workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -174,16 +201,24 @@ async def get( :type workspace_name: str :param saved_search_id: The id of the saved search. :type saved_search_id: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SavedSearch, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.SavedSearch :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SavedSearch"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SavedSearch] request = build_get_request( @@ -191,12 +226,19 @@ async def get( resource_group_name=resource_group_name, workspace_name=workspace_name, saved_search_id=saved_search_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -210,7 +252,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches/{savedSearchId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches/{savedSearchId}"} # type: ignore @distributed_trace_async @@ -219,35 +261,50 @@ async def list_by_workspace( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> "_models.SavedSearchesListResult": + ) -> _models.SavedSearchesListResult: """Gets the saved searches for a given Log Analytics Workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SavedSearchesListResult, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.SavedSearchesListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SavedSearchesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SavedSearchesListResult] request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_workspace.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -261,5 +318,5 @@ async def list_by_workspace( return deserialized - list_by_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches'} # type: ignore + list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_schema_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_schema_operations.py index 07f00cee84f5..d96c9d711559 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_schema_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_schema_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SchemaOperations: - """SchemaOperations 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.aio.LogAnalyticsManagementClient`'s + :attr:`schema` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -50,35 +48,50 @@ async def get( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> "_models.SearchGetSchemaResponse": + ) -> _models.SearchGetSchemaResponse: """Gets the schema for a given workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SearchGetSchemaResponse, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.SearchGetSchemaResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SearchGetSchemaResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SearchGetSchemaResponse] request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,5 +105,5 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/schema'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/schema"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_shared_keys_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_shared_keys_operations.py index c7caab3d8060..c89033ba5077 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_shared_keys_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_shared_keys_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SharedKeysOperations: - """SharedKeysOperations 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.aio.LogAnalyticsManagementClient`'s + :attr:`shared_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get_shared_keys( @@ -50,35 +48,50 @@ async def get_shared_keys( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> "_models.SharedKeys": + ) -> _models.SharedKeys: """Gets the shared keys for a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SharedKeys, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.SharedKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedKeys"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedKeys] request = build_get_shared_keys_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_shared_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,7 +105,7 @@ async def get_shared_keys( return deserialized - get_shared_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/sharedKeys'} # type: ignore + get_shared_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/sharedKeys"} # type: ignore @distributed_trace_async @@ -101,7 +114,7 @@ async def regenerate( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> "_models.SharedKeys": + ) -> _models.SharedKeys: """Regenerates the shared keys for a Log Analytics Workspace. These keys are used to connect Microsoft Operational Insights agents to the workspace. @@ -109,28 +122,43 @@ async def regenerate( :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SharedKeys, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.SharedKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedKeys"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedKeys] request = build_regenerate_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + api_version=api_version, template_url=self.regenerate.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -144,5 +172,5 @@ async def regenerate( return deserialized - regenerate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/regenerateSharedKey'} # type: ignore + regenerate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/regenerateSharedKey"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_storage_insight_configs_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_storage_insight_configs_operations.py index debaecc190a7..1a3f417e5812 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_storage_insight_configs_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_storage_insight_configs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class StorageInsightConfigsOperations: - """StorageInsightConfigsOperations 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.aio.LogAnalyticsManagementClient`'s + :attr:`storage_insight_configs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create_or_update( @@ -52,9 +50,9 @@ async def create_or_update( resource_group_name: str, workspace_name: str, storage_insight_name: str, - parameters: "_models.StorageInsight", + parameters: _models.StorageInsight, **kwargs: Any - ) -> "_models.StorageInsight": + ) -> _models.StorageInsight: """Create or update a storage insight. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -65,18 +63,25 @@ async def create_or_update( :type storage_insight_name: str :param parameters: The parameters required to create or update a storage insight. :type parameters: ~azure.mgmt.loganalytics.models.StorageInsight + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageInsight, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.StorageInsight :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageInsight"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageInsight] _json = self._serialize.body(parameters, 'StorageInsight') @@ -85,14 +90,21 @@ async def create_or_update( workspace_name=workspace_name, storage_insight_name=storage_insight_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -110,7 +122,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs/{storageInsightName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs/{storageInsightName}"} # type: ignore @distributed_trace_async @@ -120,7 +132,7 @@ async def get( workspace_name: str, storage_insight_name: str, **kwargs: Any - ) -> "_models.StorageInsight": + ) -> _models.StorageInsight: """Gets a storage insight instance. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -129,16 +141,24 @@ async def get( :type workspace_name: str :param storage_insight_name: Name of the storageInsightsConfigs resource. :type storage_insight_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageInsight, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.StorageInsight :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageInsight"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageInsight] request = build_get_request( @@ -146,12 +166,19 @@ async def get( workspace_name=workspace_name, storage_insight_name=storage_insight_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -165,11 +192,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs/{storageInsightName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs/{storageInsightName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, @@ -184,16 +211,24 @@ async def delete( :type workspace_name: str :param storage_insight_name: Name of the storageInsightsConfigs resource. :type storage_insight_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -201,12 +236,19 @@ async def delete( workspace_name=workspace_name, storage_insight_name=storage_insight_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -216,7 +258,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs/{storageInsightName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs/{storageInsightName}"} # type: ignore @distributed_trace @@ -225,13 +267,16 @@ def list_by_workspace( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> AsyncIterable["_models.StorageInsightListResult"]: + ) -> AsyncIterable[_models.StorageInsightListResult]: """Lists the storage insight instances within a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageInsightListResult or the result of cls(response) @@ -239,11 +284,16 @@ def list_by_workspace( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.loganalytics.models.StorageInsightListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageInsightListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageInsightListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -251,10 +301,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_workspace.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -262,10 +315,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -279,7 +335,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -292,4 +352,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs'} # type: ignore + list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_tables_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_tables_operations.py index 97ad0c79daf5..1cfeb4326088 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_tables_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_tables_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -27,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TablesOperations: - """TablesOperations 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.aio.LogAnalyticsManagementClient`'s + :attr:`tables` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_workspace( @@ -54,24 +52,32 @@ def list_by_workspace( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> AsyncIterable["_models.TablesListResult"]: + ) -> AsyncIterable[_models.TablesListResult]: """Gets all the tables for the specified Log Analytics workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TablesListResult or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.loganalytics.models.TablesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TablesListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TablesListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,10 +85,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + api_version=api_version, template_url=self.list_by_workspace.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -90,10 +99,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -107,7 +119,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,23 +137,27 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables'} # type: ignore + list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, table_name: str, - parameters: "_models.Table", + parameters: _models.Table, **kwargs: Any - ) -> Optional["_models.Table"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Table"]] + ) -> Optional[_models.Table]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Table]] _json = self._serialize.body(parameters, 'Table') @@ -146,14 +166,21 @@ async def _create_or_update_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, table_name=table_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -169,7 +196,7 @@ async def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}"} # type: ignore @distributed_trace_async @@ -178,9 +205,9 @@ async def begin_create_or_update( resource_group_name: str, workspace_name: str, table_name: str, - parameters: "_models.Table", + parameters: _models.Table, **kwargs: Any - ) -> AsyncLROPoller["_models.Table"]: + ) -> AsyncLROPoller[_models.Table]: """Update or Create a Log Analytics workspace table. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -191,6 +218,9 @@ async def begin_create_or_update( :type table_name: str :param parameters: The parameters required to update table properties. :type parameters: ~azure.mgmt.loganalytics.models.Table + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: 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 @@ -203,36 +233,48 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.loganalytics.models.Table] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 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( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, table_name=table_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('Table', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -241,26 +283,29 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}"} # type: ignore async def _update_initial( self, resource_group_name: str, workspace_name: str, table_name: str, - parameters: "_models.Table", + parameters: _models.Table, **kwargs: Any - ) -> Optional["_models.Table"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Table"]] + ) -> Optional[_models.Table]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Table]] _json = self._serialize.body(parameters, 'Table') @@ -269,14 +314,21 @@ async def _update_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, table_name=table_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -292,7 +344,7 @@ async def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}"} # type: ignore @distributed_trace_async @@ -301,9 +353,9 @@ async def begin_update( resource_group_name: str, workspace_name: str, table_name: str, - parameters: "_models.Table", + parameters: _models.Table, **kwargs: Any - ) -> AsyncLROPoller["_models.Table"]: + ) -> AsyncLROPoller[_models.Table]: """Update a Log Analytics workspace table. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -314,6 +366,9 @@ async def begin_update( :type table_name: str :param parameters: The parameters required to update table properties. :type parameters: ~azure.mgmt.loganalytics.models.Table + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: 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 @@ -326,36 +381,48 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.loganalytics.models.Table] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 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._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, table_name=table_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('Table', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -364,10 +431,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}"} # type: ignore @distributed_trace_async async def get( @@ -376,7 +442,7 @@ async def get( workspace_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Gets a Log Analytics workspace table. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -385,16 +451,24 @@ async def get( :type workspace_name: str :param table_name: The name of the table. :type table_name: str + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Table, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_get_request( @@ -402,12 +476,19 @@ async def get( resource_group_name=resource_group_name, workspace_name=workspace_name, table_name=table_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -422,21 +503,26 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}"} # type: ignore - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, table_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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -444,12 +530,19 @@ async def _delete_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, table_name=table_name, + api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -459,11 +552,11 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}"} # type: ignore @distributed_trace_async - async def begin_delete( + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, @@ -478,6 +571,9 @@ async def begin_delete( :type workspace_name: str :param table_name: The name of the table. :type table_name: str + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: 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 @@ -490,19 +586,26 @@ async def begin_delete( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 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( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, table_name=table_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -512,8 +615,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -522,13 +631,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}"} # type: ignore @distributed_trace_async - async def migrate( + async def migrate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, @@ -544,16 +652,24 @@ async def migrate( :type workspace_name: str :param table_name: The name of the table. :type table_name: str + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_migrate_request( @@ -561,12 +677,19 @@ async def migrate( resource_group_name=resource_group_name, workspace_name=workspace_name, table_name=table_name, + api_version=api_version, template_url=self.migrate.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -577,5 +700,5 @@ async def migrate( if cls: return cls(pipeline_response, None, {}) - migrate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}/migrate'} # type: ignore + migrate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}/migrate"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_usages_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_usages_operations.py index 41fe53c7f1fe..26cbc91c6b9c 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_usages_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,26 +24,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UsagesOperations: - """UsagesOperations 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.aio.LogAnalyticsManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,13 +49,16 @@ def list( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> AsyncIterable["_models.WorkspaceListUsagesResult"]: + ) -> AsyncIterable[_models.WorkspaceListUsagesResult]: """Gets a list of usage metrics for a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkspaceListUsagesResult or the result of cls(response) @@ -66,11 +66,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.loganalytics.models.WorkspaceListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceListUsagesResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspaceListUsagesResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -78,10 +83,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -89,10 +97,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -106,7 +117,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,4 +134,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/usages'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/usages"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_workspace_purge_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_workspace_purge_operations.py index d4b38b6364ee..7749b080f369 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_workspace_purge_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_workspace_purge_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,35 +23,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class WorkspacePurgeOperations: - """WorkspacePurgeOperations 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.aio.LogAnalyticsManagementClient`'s + :attr:`workspace_purge` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def purge( self, resource_group_name: str, workspace_name: str, - body: "_models.WorkspacePurgeBody", + body: _models.WorkspacePurgeBody, **kwargs: Any - ) -> "_models.WorkspacePurgeResponse": + ) -> _models.WorkspacePurgeResponse: """Purges data in an Log Analytics workspace by a set of user-defined filters. In order to manage system resources, purge requests are throttled at 50 requests per hour. You @@ -59,6 +57,9 @@ async def purge( includes all user identities that require purging. Use the in operator to specify multiple identities. You should run the query prior to using for a purge request to verify that the results are expected. + Log Analytics only supports purge operations required for compliance with GDPR. The Log + Analytics product team reserves the right to reject requests for purge operations that are not + for the purpose of GDPR compliance. In the event of a dispute, please create a support ticket. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str @@ -67,18 +68,25 @@ async def purge( :param body: Describes the body of a request to purge data in a single table of an Log Analytics Workspace. :type body: ~azure.mgmt.loganalytics.models.WorkspacePurgeBody + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkspacePurgeResponse, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.WorkspacePurgeResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspacePurgeResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspacePurgeResponse] _json = self._serialize.body(body, 'WorkspacePurgeBody') @@ -86,14 +94,21 @@ async def purge( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, workspace_name=workspace_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.purge.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [202]: @@ -110,7 +125,7 @@ async def purge( return deserialized - purge.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/purge'} # type: ignore + purge.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/purge"} # type: ignore @distributed_trace_async @@ -120,7 +135,7 @@ async def get_purge_status( workspace_name: str, purge_id: str, **kwargs: Any - ) -> "_models.WorkspacePurgeStatusResponse": + ) -> _models.WorkspacePurgeStatusResponse: """Gets status of an ongoing purge operation. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -130,16 +145,24 @@ async def get_purge_status( :param purge_id: In a purge status request, this is the Id of the operation the status of which is returned. :type purge_id: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkspacePurgeStatusResponse, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.WorkspacePurgeStatusResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspacePurgeStatusResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspacePurgeStatusResponse] request = build_get_purge_status_request( @@ -147,12 +170,19 @@ async def get_purge_status( subscription_id=self._config.subscription_id, workspace_name=workspace_name, purge_id=purge_id, + api_version=api_version, template_url=self.get_purge_status.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -166,5 +196,5 @@ async def get_purge_status( return deserialized - get_purge_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/operations/{purgeId}'} # type: ignore + get_purge_status.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/operations/{purgeId}"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_workspaces_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_workspaces_operations.py index a2283db3a27e..0dad6626b95c 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_workspaces_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_workspaces_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -27,63 +27,75 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class WorkspacesOperations: - """WorkspacesOperations 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.aio.LogAnalyticsManagementClient`'s + :attr:`workspaces` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.WorkspaceListResult"]: + ) -> AsyncIterable[_models.WorkspaceListResult]: """Gets the workspaces in a subscription. + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkspaceListResult or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.loganalytics.models.WorkspaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspaceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -97,7 +109,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -111,49 +127,63 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/workspaces'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/workspaces"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.WorkspaceListResult"]: + ) -> AsyncIterable[_models.WorkspaceListResult]: """Gets workspaces in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkspaceListResult or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.loganalytics.models.WorkspaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspaceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -167,7 +197,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,22 +215,26 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, - parameters: "_models.Workspace", + parameters: _models.Workspace, **kwargs: Any - ) -> Optional["_models.Workspace"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Workspace"]] + ) -> Optional[_models.Workspace]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Workspace]] _json = self._serialize.body(parameters, 'Workspace') @@ -204,14 +242,21 @@ async def _create_or_update_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -230,7 +275,7 @@ async def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}"} # type: ignore @distributed_trace_async @@ -238,9 +283,9 @@ async def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - parameters: "_models.Workspace", + parameters: _models.Workspace, **kwargs: Any - ) -> AsyncLROPoller["_models.Workspace"]: + ) -> AsyncLROPoller[_models.Workspace]: """Create or update a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -249,6 +294,9 @@ async def begin_create_or_update( :type workspace_name: str :param parameters: The parameters required to create or update a workspace. :type parameters: ~azure.mgmt.loganalytics.models.Workspace + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: 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 @@ -262,35 +310,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.loganalytics.models.Workspace] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Workspace"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Workspace] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 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( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('Workspace', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -299,36 +359,47 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}"} # type: ignore - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, force: Optional[bool] = None, **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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, force=force, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -338,11 +409,11 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}"} # type: ignore @distributed_trace_async - async def begin_delete( + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, @@ -359,8 +430,11 @@ async def begin_delete( :param workspace_name: The name of the workspace. :type workspace_name: str :param force: Deletes the workspace without the recovery option. A workspace that was deleted - with this flag cannot be recovered. + with this flag cannot be recovered. Default value is None. :type force: bool + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: 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 @@ -373,19 +447,26 @@ async def begin_delete( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 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( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, force=force, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -395,8 +476,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -405,10 +492,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}"} # type: ignore @distributed_trace_async async def get( @@ -416,35 +502,50 @@ async def get( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> "_models.Workspace": + ) -> _models.Workspace: """Gets a workspace instance. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Workspace, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.Workspace :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Workspace"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Workspace] request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -459,7 +560,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}"} # type: ignore @distributed_trace_async @@ -467,9 +568,9 @@ async def update( self, resource_group_name: str, workspace_name: str, - parameters: "_models.WorkspacePatch", + parameters: _models.WorkspacePatch, **kwargs: Any - ) -> "_models.Workspace": + ) -> _models.Workspace: """Updates a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -478,18 +579,25 @@ async def update( :type workspace_name: str :param parameters: The parameters required to patch a workspace. :type parameters: ~azure.mgmt.loganalytics.models.WorkspacePatch + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Workspace, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.Workspace :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Workspace"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Workspace] _json = self._serialize.body(parameters, 'WorkspacePatch') @@ -497,14 +605,21 @@ async def update( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -519,5 +634,5 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/__init__.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/__init__.py index 9902fdc4c1f9..cd42ad0c3f8a 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/__init__.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/__init__.py @@ -116,7 +116,9 @@ WorkspaceEntityStatus, WorkspaceSkuNameEnum, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'AssociatedWorkspace', 'AvailableServiceTier', @@ -225,3 +227,5 @@ 'WorkspaceEntityStatus', 'WorkspaceSkuNameEnum', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_log_analytics_management_client_enums.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_log_analytics_management_client_enums.py index 58a535011f16..b28301bb1d7d 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_log_analytics_management_client_enums.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_log_analytics_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class BillingType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class BillingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Configures whether billing will be only on the cluster or each workspace will be billed by its proportional use. This does not change the overall billing, only how it will be distributed. Default value is 'Cluster' @@ -20,7 +19,7 @@ class BillingType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CLUSTER = "Cluster" WORKSPACES = "Workspaces" -class Capacity(with_metaclass(CaseInsensitiveEnumMeta, int, Enum)): +class Capacity(int, Enum, metaclass=CaseInsensitiveEnumMeta): """The capacity value """ @@ -29,7 +28,7 @@ class Capacity(with_metaclass(CaseInsensitiveEnumMeta, int, Enum)): TWO_THOUSAND = 2000 FIVE_THOUSAND = 5000 -class CapacityReservationLevel(with_metaclass(CaseInsensitiveEnumMeta, int, Enum)): +class CapacityReservationLevel(int, Enum, metaclass=CaseInsensitiveEnumMeta): """The capacity reservation level in GB for this workspace, when CapacityReservation sku is selected. """ @@ -43,7 +42,7 @@ class CapacityReservationLevel(with_metaclass(CaseInsensitiveEnumMeta, int, Enum TWO_THOUSAND = 2000 FIVE_THOUSAND = 5000 -class ClusterEntityStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ClusterEntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state of the cluster. """ @@ -55,13 +54,13 @@ class ClusterEntityStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PROVISIONING_ACCOUNT = "ProvisioningAccount" UPDATING = "Updating" -class ClusterSkuNameEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ClusterSkuNameEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The name of the SKU. """ CAPACITY_RESERVATION = "CapacityReservation" -class ColumnDataTypeHintEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ColumnDataTypeHintEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Column data type logical hint. """ @@ -76,7 +75,7 @@ class ColumnDataTypeHintEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)) #: A standard V4/V6 ip address following the standard shape, x.x.x.x/y:y:y:y:y:y:y:y. IP = "ip" -class ColumnTypeEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ColumnTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Column data type. """ @@ -89,7 +88,7 @@ class ColumnTypeEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): GUID = "guid" DYNAMIC = "dynamic" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource. """ @@ -98,7 +97,7 @@ class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DataIngestionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DataIngestionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of data ingestion for this workspace. """ @@ -115,7 +114,7 @@ class DataIngestionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: 80% of daily cap quota reached. APPROACHING_QUOTA = "ApproachingQuota" -class DataSourceKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DataSourceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The kind of the DataSource. """ @@ -153,16 +152,17 @@ class DataSourceKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): APPLICATION_INSIGHTS = "ApplicationInsights" SQL_DATA_CLASSIFICATION = "SqlDataClassification" -class DataSourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DataSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Linked storage accounts type. """ CUSTOM_LOGS = "CustomLogs" AZURE_WATSON = "AzureWatson" QUERY = "Query" + INGESTION = "Ingestion" ALERTS = "Alerts" -class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that creates/modifies resources """ @@ -174,7 +174,7 @@ class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): USER_ASSIGNED = "UserAssigned" NONE = "None" -class LinkedServiceEntityStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LinkedServiceEntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state of the linked service. """ @@ -183,7 +183,7 @@ class LinkedServiceEntityStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enu PROVISIONING_ACCOUNT = "ProvisioningAccount" UPDATING = "Updating" -class ProvisioningStateEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningStateEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Table's current provisioning state. If set to 'updating', indicates a resource lock due to ongoing operation, forbidding any update to the table until the ongoing operation is concluded. """ @@ -196,7 +196,7 @@ class ProvisioningStateEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Table state is stable and without changes, table is unlocked and open for new updates. SUCCEEDED = "Succeeded" -class PublicNetworkAccessType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicNetworkAccessType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The network access type for operating on the Log Analytics Workspace. By default it is Enabled """ @@ -205,21 +205,21 @@ class PublicNetworkAccessType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) #: Disables public connectivity to Log Analytics through public DNS. DISABLED = "Disabled" -class PurgeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PurgeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Status of the operation represented by the requested Id. """ PENDING = "pending" COMPLETED = "completed" -class SearchSortEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SearchSortEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sort order of the search. """ ASC = "asc" DESC = "desc" -class SkuNameEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuNameEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The name of the Service Tier. """ @@ -231,7 +231,7 @@ class SkuNameEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDALONE = "Standalone" CAPACITY_RESERVATION = "CapacityReservation" -class SourceEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SourceEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Table's creator. """ @@ -241,14 +241,14 @@ class SourceEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Tables created by the owner of the Workspace, and only found in this Workspace. CUSTOMER = "customer" -class StorageInsightState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageInsightState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the storage insight connection to the workspace """ OK = "OK" ERROR = "ERROR" -class TablePlanEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class TablePlanEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Instruct the system how to handle and charge the logs ingested to this table. """ @@ -257,7 +257,7 @@ class TablePlanEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Logs that allow monitoring and analytics. ANALYTICS = "Analytics" -class TableSubTypeEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class TableSubTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The subtype describes what APIs can be used to interact with the table, and what features are available against it. """ @@ -272,7 +272,7 @@ class TableSubTypeEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: provided by Data Collection Rules. DATA_COLLECTION_RULE_BASED = "DataCollectionRuleBased" -class TableTypeEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class TableTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Table's creator. """ @@ -285,14 +285,14 @@ class TableTypeEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Data collected by a search job. SEARCH_RESULTS = "SearchResults" -class Type(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of the destination resource """ STORAGE_ACCOUNT = "StorageAccount" EVENT_HUB = "EventHub" -class WorkspaceEntityStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class WorkspaceEntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state of the workspace. """ @@ -304,7 +304,7 @@ class WorkspaceEntityStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PROVISIONING_ACCOUNT = "ProvisioningAccount" UPDATING = "Updating" -class WorkspaceSkuNameEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class WorkspaceSkuNameEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The name of the SKU. """ diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_models_py3.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_models_py3.py index 85b9a107ee15..27bfa2ed9dad 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_models_py3.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_models_py3.py @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._log_analytics_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AssociatedWorkspace(msrest.serialization.Model): @@ -62,7 +64,7 @@ class AvailableServiceTier(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar service_tier: The name of the Service Tier. Possible values include: "Free", "Standard", + :ivar service_tier: The name of the Service Tier. Known values are: "Free", "Standard", "Premium", "PerNode", "PerGB2018", "Standalone", "CapacityReservation". :vartype service_tier: str or ~azure.mgmt.loganalytics.models.SkuNameEnum :ivar enabled: True if the Service Tier is enabled for the workspace. @@ -350,8 +352,8 @@ class Cluster(TrackedResource): :vartype sku: ~azure.mgmt.loganalytics.models.ClusterSku :ivar cluster_id: The ID associated with the cluster. :vartype cluster_id: str - :ivar provisioning_state: The provisioning state of the cluster. Possible values include: - "Creating", "Succeeded", "Failed", "Canceled", "Deleting", "ProvisioningAccount", "Updating". + :ivar provisioning_state: The provisioning state of the cluster. Known values are: "Creating", + "Succeeded", "Failed", "Canceled", "Deleting", "ProvisioningAccount", "Updating". :vartype provisioning_state: str or ~azure.mgmt.loganalytics.models.ClusterEntityStatus :ivar is_double_encryption_enabled: Configures whether cluster will use double encryption. This Property can not be modified after cluster creation. Default value is 'true'. @@ -361,8 +363,7 @@ class Cluster(TrackedResource): This Property can not be modified after cluster creation. Default value is 'true' if region supports Availability Zones. :vartype is_availability_zones_enabled: bool - :ivar billing_type: The cluster's billing type. Possible values include: "Cluster", - "Workspaces". + :ivar billing_type: The cluster's billing type. Known values are: "Cluster", "Workspaces". :vartype billing_type: str or ~azure.mgmt.loganalytics.models.BillingType :ivar key_vault_properties: The associated key properties. :vartype key_vault_properties: ~azure.mgmt.loganalytics.models.KeyVaultProperties @@ -413,14 +414,14 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - sku: Optional["ClusterSku"] = None, + identity: Optional["_models.Identity"] = None, + sku: Optional["_models.ClusterSku"] = None, is_double_encryption_enabled: Optional[bool] = None, is_availability_zones_enabled: Optional[bool] = None, - billing_type: Optional[Union[str, "BillingType"]] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, - associated_workspaces: Optional[List["AssociatedWorkspace"]] = None, - capacity_reservation_properties: Optional["CapacityReservationProperties"] = None, + billing_type: Optional[Union[str, "_models.BillingType"]] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, + associated_workspaces: Optional[List["_models.AssociatedWorkspace"]] = None, + capacity_reservation_properties: Optional["_models.CapacityReservationProperties"] = None, **kwargs ): """ @@ -440,8 +441,7 @@ def __init__( Zones. This Property can not be modified after cluster creation. Default value is 'true' if region supports Availability Zones. :paramtype is_availability_zones_enabled: bool - :keyword billing_type: The cluster's billing type. Possible values include: "Cluster", - "Workspaces". + :keyword billing_type: The cluster's billing type. Known values are: "Cluster", "Workspaces". :paramtype billing_type: str or ~azure.mgmt.loganalytics.models.BillingType :keyword key_vault_properties: The associated key properties. :paramtype key_vault_properties: ~azure.mgmt.loganalytics.models.KeyVaultProperties @@ -485,7 +485,7 @@ def __init__( self, *, next_link: Optional[str] = None, - value: Optional[List["Cluster"]] = None, + value: Optional[List["_models.Cluster"]] = None, **kwargs ): """ @@ -510,8 +510,7 @@ class ClusterPatch(msrest.serialization.Model): :vartype tags: dict[str, str] :ivar key_vault_properties: The associated key properties. :vartype key_vault_properties: ~azure.mgmt.loganalytics.models.KeyVaultProperties - :ivar billing_type: The cluster's billing type. Possible values include: "Cluster", - "Workspaces". + :ivar billing_type: The cluster's billing type. Known values are: "Cluster", "Workspaces". :vartype billing_type: str or ~azure.mgmt.loganalytics.models.BillingType """ @@ -526,11 +525,11 @@ class ClusterPatch(msrest.serialization.Model): def __init__( self, *, - identity: Optional["Identity"] = None, - sku: Optional["ClusterSku"] = None, + identity: Optional["_models.Identity"] = None, + sku: Optional["_models.ClusterSku"] = None, tags: Optional[Dict[str, str]] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, - billing_type: Optional[Union[str, "BillingType"]] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, + billing_type: Optional[Union[str, "_models.BillingType"]] = None, **kwargs ): """ @@ -542,8 +541,7 @@ def __init__( :paramtype tags: dict[str, str] :keyword key_vault_properties: The associated key properties. :paramtype key_vault_properties: ~azure.mgmt.loganalytics.models.KeyVaultProperties - :keyword billing_type: The cluster's billing type. Possible values include: "Cluster", - "Workspaces". + :keyword billing_type: The cluster's billing type. Known values are: "Cluster", "Workspaces". :paramtype billing_type: str or ~azure.mgmt.loganalytics.models.BillingType """ super(ClusterPatch, self).__init__(**kwargs) @@ -557,9 +555,9 @@ def __init__( class ClusterSku(msrest.serialization.Model): """The cluster sku definition. - :ivar capacity: The capacity value. Possible values include: 500, 1000, 2000, 5000. + :ivar capacity: The capacity value. Known values are: 500, 1000, 2000, 5000. :vartype capacity: int or ~azure.mgmt.loganalytics.models.Capacity - :ivar name: The name of the SKU. Possible values include: "CapacityReservation". + :ivar name: The name of the SKU. Known values are: "CapacityReservation". :vartype name: str or ~azure.mgmt.loganalytics.models.ClusterSkuNameEnum """ @@ -571,14 +569,14 @@ class ClusterSku(msrest.serialization.Model): def __init__( self, *, - capacity: Optional[Union[int, "Capacity"]] = None, - name: Optional[Union[str, "ClusterSkuNameEnum"]] = None, + capacity: Optional[Union[int, "_models.Capacity"]] = None, + name: Optional[Union[str, "_models.ClusterSkuNameEnum"]] = None, **kwargs ): """ - :keyword capacity: The capacity value. Possible values include: 500, 1000, 2000, 5000. + :keyword capacity: The capacity value. Known values are: 500, 1000, 2000, 5000. :paramtype capacity: int or ~azure.mgmt.loganalytics.models.Capacity - :keyword name: The name of the SKU. Possible values include: "CapacityReservation". + :keyword name: The name of the SKU. Known values are: "CapacityReservation". :paramtype name: str or ~azure.mgmt.loganalytics.models.ClusterSkuNameEnum """ super(ClusterSku, self).__init__(**kwargs) @@ -593,10 +591,10 @@ class Column(msrest.serialization.Model): :ivar name: Column name. :vartype name: str - :ivar type: Column data type. Possible values include: "string", "int", "long", "real", - "boolean", "dateTime", "guid", "dynamic". + :ivar type: Column data type. Known values are: "string", "int", "long", "real", "boolean", + "dateTime", "guid", "dynamic". :vartype type: str or ~azure.mgmt.loganalytics.models.ColumnTypeEnum - :ivar data_type_hint: Column data type logical hint. Possible values include: "uri", "guid", + :ivar data_type_hint: Column data type logical hint. Known values are: "uri", "guid", "armPath", "ip". :vartype data_type_hint: str or ~azure.mgmt.loganalytics.models.ColumnDataTypeHintEnum :ivar display_name: Column display name. @@ -628,8 +626,8 @@ def __init__( self, *, name: Optional[str] = None, - type: Optional[Union[str, "ColumnTypeEnum"]] = None, - data_type_hint: Optional[Union[str, "ColumnDataTypeHintEnum"]] = None, + type: Optional[Union[str, "_models.ColumnTypeEnum"]] = None, + data_type_hint: Optional[Union[str, "_models.ColumnDataTypeHintEnum"]] = None, display_name: Optional[str] = None, description: Optional[str] = None, **kwargs @@ -637,10 +635,10 @@ def __init__( """ :keyword name: Column name. :paramtype name: str - :keyword type: Column data type. Possible values include: "string", "int", "long", "real", - "boolean", "dateTime", "guid", "dynamic". + :keyword type: Column data type. Known values are: "string", "int", "long", "real", "boolean", + "dateTime", "guid", "dynamic". :paramtype type: str or ~azure.mgmt.loganalytics.models.ColumnTypeEnum - :keyword data_type_hint: Column data type logical hint. Possible values include: "uri", "guid", + :keyword data_type_hint: Column data type logical hint. Known values are: "uri", "guid", "armPath", "ip". :paramtype data_type_hint: str or ~azure.mgmt.loganalytics.models.ColumnDataTypeHintEnum :keyword display_name: Column display name. @@ -758,8 +756,8 @@ class DataExport(ProxyResource): :ivar resource_id: The destination resource ID. This can be copied from the Properties entry of the destination resource in Azure. :vartype resource_id: str - :ivar type_properties_destination_type: The type of the destination resource. Possible values - include: "StorageAccount", "EventHub". + :ivar type_properties_destination_type: The type of the destination resource. Known values are: + "StorageAccount", "EventHub". :vartype type_properties_destination_type: str or ~azure.mgmt.loganalytics.models.Type :ivar event_hub_name: Optional. Allows to define an Event Hub name. Not applicable when destination is Storage Account. @@ -842,7 +840,7 @@ class DataExportListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["DataExport"]] = None, + value: Optional[List["_models.DataExport"]] = None, **kwargs ): """ @@ -873,7 +871,7 @@ class DataSource(ProxyResource): :vartype properties: any :ivar etag: The ETag of the data source. :vartype etag: str - :ivar kind: Required. The kind of the DataSource. Possible values include: "WindowsEvent", + :ivar kind: Required. The kind of the DataSource. Known values are: "WindowsEvent", "WindowsPerformanceCounter", "IISLogs", "LinuxSyslog", "LinuxSyslogCollection", "LinuxPerformanceObject", "LinuxPerformanceCollection", "CustomLog", "CustomLogCollection", "AzureAuditLog", "AzureActivityLog", "GenericDataSource", "ChangeTrackingCustomPath", @@ -911,7 +909,7 @@ def __init__( self, *, properties: Any, - kind: Union[str, "DataSourceKind"], + kind: Union[str, "_models.DataSourceKind"], etag: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs @@ -922,7 +920,7 @@ def __init__( :paramtype properties: any :keyword etag: The ETag of the data source. :paramtype etag: str - :keyword kind: Required. The kind of the DataSource. Possible values include: "WindowsEvent", + :keyword kind: Required. The kind of the DataSource. Known values are: "WindowsEvent", "WindowsPerformanceCounter", "IISLogs", "LinuxSyslog", "LinuxSyslogCollection", "LinuxPerformanceObject", "LinuxPerformanceCollection", "CustomLog", "CustomLogCollection", "AzureAuditLog", "AzureActivityLog", "GenericDataSource", "ChangeTrackingCustomPath", @@ -947,7 +945,7 @@ def __init__( class DataSourceFilter(msrest.serialization.Model): """DataSource filter. Right now, only filter by kind is supported. - :ivar kind: The kind of the DataSource. Possible values include: "WindowsEvent", + :ivar kind: The kind of the DataSource. Known values are: "WindowsEvent", "WindowsPerformanceCounter", "IISLogs", "LinuxSyslog", "LinuxSyslogCollection", "LinuxPerformanceObject", "LinuxPerformanceCollection", "CustomLog", "CustomLogCollection", "AzureAuditLog", "AzureActivityLog", "GenericDataSource", "ChangeTrackingCustomPath", @@ -968,11 +966,11 @@ class DataSourceFilter(msrest.serialization.Model): def __init__( self, *, - kind: Optional[Union[str, "DataSourceKind"]] = None, + kind: Optional[Union[str, "_models.DataSourceKind"]] = None, **kwargs ): """ - :keyword kind: The kind of the DataSource. Possible values include: "WindowsEvent", + :keyword kind: The kind of the DataSource. Known values are: "WindowsEvent", "WindowsPerformanceCounter", "IISLogs", "LinuxSyslog", "LinuxSyslogCollection", "LinuxPerformanceObject", "LinuxPerformanceCollection", "CustomLog", "CustomLogCollection", "AzureAuditLog", "AzureActivityLog", "GenericDataSource", "ChangeTrackingCustomPath", @@ -1006,7 +1004,7 @@ class DataSourceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["DataSource"]] = None, + value: Optional[List["_models.DataSource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -1114,7 +1112,7 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorDetail"] = None, + error: Optional["_models.ErrorDetail"] = None, **kwargs ): """ @@ -1136,7 +1134,7 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: Required. Type of managed service identity. Possible values include: "user", + :ivar type: Required. Type of managed service identity. Known values are: "user", "application", "managedIdentity", "key", "SystemAssigned", "UserAssigned", "None". :vartype type: str or ~azure.mgmt.loganalytics.models.IdentityType :ivar user_assigned_identities: The list of user identities associated with the resource. The @@ -1162,12 +1160,12 @@ class Identity(msrest.serialization.Model): def __init__( self, *, - type: Union[str, "IdentityType"], - user_assigned_identities: Optional[Dict[str, "UserIdentityProperties"]] = None, + type: Union[str, "_models.IdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserIdentityProperties"]] = None, **kwargs ): """ - :keyword type: Required. Type of managed service identity. Possible values include: "user", + :keyword type: Required. Type of managed service identity. Known values are: "user", "application", "managedIdentity", "key", "SystemAssigned", "UserAssigned", "None". :paramtype type: str or ~azure.mgmt.loganalytics.models.IdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. @@ -1291,8 +1289,8 @@ class LinkedService(ProxyResource): :ivar write_access_resource_id: The resource id of the resource that will be linked to the workspace. This should be used for linking resources which require write access. :vartype write_access_resource_id: str - :ivar provisioning_state: The provisioning state of the linked service. Possible values - include: "Succeeded", "Deleting", "ProvisioningAccount", "Updating". + :ivar provisioning_state: The provisioning state of the linked service. Known values are: + "Succeeded", "Deleting", "ProvisioningAccount", "Updating". :vartype provisioning_state: str or ~azure.mgmt.loganalytics.models.LinkedServiceEntityStatus """ @@ -1318,7 +1316,7 @@ def __init__( tags: Optional[Dict[str, str]] = None, resource_id: Optional[str] = None, write_access_resource_id: Optional[str] = None, - provisioning_state: Optional[Union[str, "LinkedServiceEntityStatus"]] = None, + provisioning_state: Optional[Union[str, "_models.LinkedServiceEntityStatus"]] = None, **kwargs ): """ @@ -1330,8 +1328,8 @@ def __init__( :keyword write_access_resource_id: The resource id of the resource that will be linked to the workspace. This should be used for linking resources which require write access. :paramtype write_access_resource_id: str - :keyword provisioning_state: The provisioning state of the linked service. Possible values - include: "Succeeded", "Deleting", "ProvisioningAccount", "Updating". + :keyword provisioning_state: The provisioning state of the linked service. Known values are: + "Succeeded", "Deleting", "ProvisioningAccount", "Updating". :paramtype provisioning_state: str or ~azure.mgmt.loganalytics.models.LinkedServiceEntityStatus """ super(LinkedService, self).__init__(**kwargs) @@ -1355,7 +1353,7 @@ class LinkedServiceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["LinkedService"]] = None, + value: Optional[List["_models.LinkedService"]] = None, **kwargs ): """ @@ -1380,7 +1378,7 @@ class LinkedStorageAccountsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["LinkedStorageAccountsResource"]] = None, + value: Optional[List["_models.LinkedStorageAccountsResource"]] = None, **kwargs ): """ @@ -1404,8 +1402,8 @@ class LinkedStorageAccountsResource(ProxyResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar data_source_type: Linked storage accounts type. Possible values include: "CustomLogs", - "AzureWatson", "Query", "Alerts". + :ivar data_source_type: Linked storage accounts type. Known values are: "CustomLogs", + "AzureWatson", "Query", "Ingestion", "Alerts". :vartype data_source_type: str or ~azure.mgmt.loganalytics.models.DataSourceType :ivar storage_account_ids: Linked storage accounts resources ids. :vartype storage_account_ids: list[str] @@ -1592,7 +1590,7 @@ class LogAnalyticsQueryPackListResult(msrest.serialization.Model): def __init__( self, *, - value: List["LogAnalyticsQueryPack"], + value: List["_models.LogAnalyticsQueryPack"], next_link: Optional[str] = None, **kwargs ): @@ -1677,7 +1675,7 @@ def __init__( display_name: Optional[str] = None, description: Optional[str] = None, body: Optional[str] = None, - related: Optional["LogAnalyticsQueryPackQueryPropertiesRelated"] = None, + related: Optional["_models.LogAnalyticsQueryPackQueryPropertiesRelated"] = None, tags: Optional[Dict[str, List[str]]] = None, properties: Optional[Any] = None, **kwargs @@ -1733,7 +1731,7 @@ class LogAnalyticsQueryPackQueryListResult(msrest.serialization.Model): def __init__( self, *, - value: List["LogAnalyticsQueryPackQuery"], + value: List["_models.LogAnalyticsQueryPackQuery"], next_link: Optional[str] = None, **kwargs ): @@ -1806,7 +1804,7 @@ class LogAnalyticsQueryPackQuerySearchProperties(msrest.serialization.Model): def __init__( self, *, - related: Optional["LogAnalyticsQueryPackQuerySearchPropertiesRelated"] = None, + related: Optional["_models.LogAnalyticsQueryPackQuerySearchPropertiesRelated"] = None, tags: Optional[Dict[str, List[str]]] = None, **kwargs ): @@ -1985,7 +1983,7 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, **kwargs ): """ @@ -2069,7 +2067,7 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, **kwargs ): """ @@ -2116,7 +2114,7 @@ def __init__( start_time: Optional[str] = None, end_time: Optional[str] = None, status: Optional[str] = None, - error: Optional["ErrorResponse"] = None, + error: Optional["_models.ErrorResponse"] = None, **kwargs ): """ @@ -2317,7 +2315,7 @@ def __init__( function_alias: Optional[str] = None, function_parameters: Optional[str] = None, version: Optional[int] = None, - tags: Optional[List["Tag"]] = None, + tags: Optional[List["_models.Tag"]] = None, **kwargs ): """ @@ -2369,7 +2367,7 @@ class SavedSearchesListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["SavedSearch"]] = None, + value: Optional[List["_models.SavedSearch"]] = None, **kwargs ): """ @@ -2399,13 +2397,13 @@ class Schema(msrest.serialization.Model): :vartype categories: list[str] :ivar labels: Table labels. :vartype labels: list[str] - :ivar source: Table's creator. Possible values include: "microsoft", "customer". + :ivar source: Table's creator. Known values are: "microsoft", "customer". :vartype source: str or ~azure.mgmt.loganalytics.models.SourceEnum - :ivar table_type: Table's creator. Possible values include: "Microsoft", "CustomLog", - "RestoredLogs", "SearchResults". + :ivar table_type: Table's creator. Known values are: "Microsoft", "CustomLog", "RestoredLogs", + "SearchResults". :vartype table_type: str or ~azure.mgmt.loganalytics.models.TableTypeEnum :ivar table_sub_type: The subtype describes what APIs can be used to interact with the table, - and what features are available against it. Possible values include: "Any", "Classic", + and what features are available against it. Known values are: "Any", "Classic", "DataCollectionRuleBased". :vartype table_sub_type: str or ~azure.mgmt.loganalytics.models.TableSubTypeEnum :ivar solutions: List of solutions the table is affiliated with. @@ -2450,7 +2448,7 @@ def __init__( name: Optional[str] = None, display_name: Optional[str] = None, description: Optional[str] = None, - columns: Optional[List["Column"]] = None, + columns: Optional[List["_models.Column"]] = None, **kwargs ): """ @@ -2496,8 +2494,8 @@ class SearchGetSchemaResponse(msrest.serialization.Model): def __init__( self, *, - metadata: Optional["SearchMetadata"] = None, - value: Optional[List["SearchSchemaValue"]] = None, + metadata: Optional["_models.SearchMetadata"] = None, + value: Optional[List["_models.SearchSchemaValue"]] = None, **kwargs ): """ @@ -2578,18 +2576,18 @@ def __init__( total: Optional[int] = None, top: Optional[int] = None, id: Optional[str] = None, - core_summaries: Optional[List["CoreSummary"]] = None, + core_summaries: Optional[List["_models.CoreSummary"]] = None, status: Optional[str] = None, start_time: Optional[datetime.datetime] = None, last_updated: Optional[datetime.datetime] = None, e_tag: Optional[str] = None, - sort: Optional[List["SearchSort"]] = None, + sort: Optional[List["_models.SearchSort"]] = None, request_time: Optional[int] = None, aggregated_value_field: Optional[str] = None, aggregated_grouping_fields: Optional[str] = None, sum: Optional[int] = None, max: Optional[int] = None, - schema: Optional["SearchMetadataSchema"] = None, + schema: Optional["_models.SearchMetadataSchema"] = None, **kwargs ): """ @@ -2823,7 +2821,7 @@ class SearchSort(msrest.serialization.Model): :ivar name: The name of the field the search query is sorted on. :vartype name: str - :ivar order: The sort order of the search. Possible values include: "asc", "desc". + :ivar order: The sort order of the search. Known values are: "asc", "desc". :vartype order: str or ~azure.mgmt.loganalytics.models.SearchSortEnum """ @@ -2836,13 +2834,13 @@ def __init__( self, *, name: Optional[str] = None, - order: Optional[Union[str, "SearchSortEnum"]] = None, + order: Optional[Union[str, "_models.SearchSortEnum"]] = None, **kwargs ): """ :keyword name: The name of the field the search query is sorted on. :paramtype name: str - :keyword order: The sort order of the search. Possible values include: "asc", "desc". + :keyword order: The sort order of the search. Known values are: "asc", "desc". :paramtype order: str or ~azure.mgmt.loganalytics.models.SearchSortEnum """ super(SearchSort, self).__init__(**kwargs) @@ -2974,7 +2972,7 @@ def __init__( tags: Optional[Dict[str, str]] = None, containers: Optional[List[str]] = None, tables: Optional[List[str]] = None, - storage_account: Optional["StorageAccount"] = None, + storage_account: Optional["_models.StorageAccount"] = None, **kwargs ): """ @@ -3015,7 +3013,7 @@ class StorageInsightListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["StorageInsight"]] = None, + value: Optional[List["_models.StorageInsight"]] = None, odata_next_link: Optional[str] = None, **kwargs ): @@ -3035,8 +3033,8 @@ class StorageInsightStatus(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar state: Required. The state of the storage insight connection to the workspace. Possible - values include: "OK", "ERROR". + :ivar state: Required. The state of the storage insight connection to the workspace. Known + values are: "OK", "ERROR". :vartype state: str or ~azure.mgmt.loganalytics.models.StorageInsightState :ivar description: Description of the state of the storage insight. :vartype description: str @@ -3054,13 +3052,13 @@ class StorageInsightStatus(msrest.serialization.Model): def __init__( self, *, - state: Union[str, "StorageInsightState"], + state: Union[str, "_models.StorageInsightState"], description: Optional[str] = None, **kwargs ): """ - :keyword state: Required. The state of the storage insight connection to the workspace. - Possible values include: "OK", "ERROR". + :keyword state: Required. The state of the storage insight connection to the workspace. Known + values are: "OK", "ERROR". :paramtype state: str or ~azure.mgmt.loganalytics.models.StorageInsightState :keyword description: Description of the state of the storage insight. :paramtype description: str @@ -3075,16 +3073,15 @@ class SystemData(msrest.serialization.Model): :ivar created_by: An identifier for the identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: + :ivar created_by_type: The type of identity that created the resource. Known values are: "user", "application", "managedIdentity", "key", "SystemAssigned", "UserAssigned", "None". :vartype created_by_type: str or ~azure.mgmt.loganalytics.models.IdentityType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: An identifier for the identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "user", "application", "managedIdentity", "key", "SystemAssigned", - "UserAssigned", "None". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "user", "application", "managedIdentity", "key", "SystemAssigned", "UserAssigned", "None". :vartype last_modified_by_type: str or ~azure.mgmt.loganalytics.models.IdentityType :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime @@ -3103,27 +3100,26 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "IdentityType"]] = None, + created_by_type: Optional[Union[str, "_models.IdentityType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "IdentityType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.IdentityType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: An identifier for the identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "user", "application", "managedIdentity", "key", "SystemAssigned", "UserAssigned", - "None". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "user", "application", "managedIdentity", "key", "SystemAssigned", "UserAssigned", "None". :paramtype created_by_type: str or ~azure.mgmt.loganalytics.models.IdentityType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: An identifier for the identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "user", "application", "managedIdentity", "key", "SystemAssigned", - "UserAssigned", "None". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "user", "application", "managedIdentity", "key", "SystemAssigned", "UserAssigned", + "None". :paramtype last_modified_by_type: str or ~azure.mgmt.loganalytics.models.IdentityType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime @@ -3142,15 +3138,15 @@ class SystemDataAutoGenerated(msrest.serialization.Model): :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: + :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", "Key". :vartype created_by_type: str or ~azure.mgmt.loganalytics.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". :vartype last_modified_by_type: str or ~azure.mgmt.loganalytics.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime @@ -3169,25 +3165,25 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". :paramtype created_by_type: str or ~azure.mgmt.loganalytics.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.loganalytics.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime @@ -3231,8 +3227,8 @@ class Table(ProxyResource): :vartype restored_logs: ~azure.mgmt.loganalytics.models.RestoredLogs :ivar result_statistics: Search job execution statistics. :vartype result_statistics: ~azure.mgmt.loganalytics.models.ResultStatistics - :ivar plan: Instruct the system how to handle and charge the logs ingested to this table. - Possible values include: "Basic", "Analytics". + :ivar plan: Instruct the system how to handle and charge the logs ingested to this table. Known + values are: "Basic", "Analytics". :vartype plan: str or ~azure.mgmt.loganalytics.models.TablePlanEnum :ivar last_plan_modified_date: The timestamp that table plan was last modified (UTC). :vartype last_plan_modified_date: str @@ -3240,7 +3236,7 @@ class Table(ProxyResource): :vartype schema: ~azure.mgmt.loganalytics.models.Schema :ivar provisioning_state: Table's current provisioning state. If set to 'updating', indicates a resource lock due to ongoing operation, forbidding any update to the table until the ongoing - operation is concluded. Possible values include: "Updating", "InProgress", "Succeeded". + operation is concluded. Known values are: "Updating", "InProgress", "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.loganalytics.models.ProvisioningStateEnum """ @@ -3278,11 +3274,11 @@ def __init__( *, retention_in_days: Optional[int] = None, total_retention_in_days: Optional[int] = None, - search_results: Optional["SearchResults"] = None, - restored_logs: Optional["RestoredLogs"] = None, - result_statistics: Optional["ResultStatistics"] = None, - plan: Optional[Union[str, "TablePlanEnum"]] = None, - schema: Optional["Schema"] = None, + search_results: Optional["_models.SearchResults"] = None, + restored_logs: Optional["_models.RestoredLogs"] = None, + result_statistics: Optional["_models.ResultStatistics"] = None, + plan: Optional[Union[str, "_models.TablePlanEnum"]] = None, + schema: Optional["_models.Schema"] = None, **kwargs ): """ @@ -3299,7 +3295,7 @@ def __init__( :keyword result_statistics: Search job execution statistics. :paramtype result_statistics: ~azure.mgmt.loganalytics.models.ResultStatistics :keyword plan: Instruct the system how to handle and charge the logs ingested to this table. - Possible values include: "Basic", "Analytics". + Known values are: "Basic", "Analytics". :paramtype plan: str or ~azure.mgmt.loganalytics.models.TablePlanEnum :keyword schema: Table schema. :paramtype schema: ~azure.mgmt.loganalytics.models.Schema @@ -3332,7 +3328,7 @@ class TablesListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Table"]] = None, + value: Optional[List["_models.Table"]] = None, **kwargs ): """ @@ -3436,7 +3432,7 @@ class UsageMetric(msrest.serialization.Model): def __init__( self, *, - name: Optional["MetricName"] = None, + name: Optional["_models.MetricName"] = None, unit: Optional[str] = None, current_value: Optional[float] = None, limit: Optional[float] = None, @@ -3523,7 +3519,7 @@ class Workspace(TrackedResource): :vartype system_data: ~azure.mgmt.loganalytics.models.SystemDataAutoGenerated :ivar e_tag: The ETag of the workspace. :vartype e_tag: str - :ivar provisioning_state: The provisioning state of the workspace. Possible values include: + :ivar provisioning_state: The provisioning state of the workspace. Known values are: "Creating", "Succeeded", "Failed", "Canceled", "Deleting", "ProvisioningAccount", "Updating". :vartype provisioning_state: str or ~azure.mgmt.loganalytics.models.WorkspaceEntityStatus :ivar customer_id: This is a read-only property. Represents the ID associated with the @@ -3541,11 +3537,11 @@ class Workspace(TrackedResource): :ivar modified_date: Workspace modification date. :vartype modified_date: str :ivar public_network_access_for_ingestion: The network access type for accessing Log Analytics - ingestion. Possible values include: "Enabled", "Disabled". Default value: "Enabled". + ingestion. Known values are: "Enabled", "Disabled". Default value: "Enabled". :vartype public_network_access_for_ingestion: str or ~azure.mgmt.loganalytics.models.PublicNetworkAccessType :ivar public_network_access_for_query: The network access type for accessing Log Analytics - query. Possible values include: "Enabled", "Disabled". Default value: "Enabled". + query. Known values are: "Enabled", "Disabled". Default value: "Enabled". :vartype public_network_access_for_query: str or ~azure.mgmt.loganalytics.models.PublicNetworkAccessType :ivar force_cmk_for_query: Indicates whether customer managed storage is mandatory for query @@ -3604,13 +3600,13 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, e_tag: Optional[str] = None, - sku: Optional["WorkspaceSku"] = None, + sku: Optional["_models.WorkspaceSku"] = None, retention_in_days: Optional[int] = None, - workspace_capping: Optional["WorkspaceCapping"] = None, - public_network_access_for_ingestion: Optional[Union[str, "PublicNetworkAccessType"]] = "Enabled", - public_network_access_for_query: Optional[Union[str, "PublicNetworkAccessType"]] = "Enabled", + workspace_capping: Optional["_models.WorkspaceCapping"] = None, + public_network_access_for_ingestion: Optional[Union[str, "_models.PublicNetworkAccessType"]] = "Enabled", + public_network_access_for_query: Optional[Union[str, "_models.PublicNetworkAccessType"]] = "Enabled", force_cmk_for_query: Optional[bool] = None, - features: Optional["WorkspaceFeatures"] = None, + features: Optional["_models.WorkspaceFeatures"] = None, default_data_collection_rule_resource_id: Optional[str] = None, **kwargs ): @@ -3629,11 +3625,11 @@ def __init__( :keyword workspace_capping: The daily volume cap for ingestion. :paramtype workspace_capping: ~azure.mgmt.loganalytics.models.WorkspaceCapping :keyword public_network_access_for_ingestion: The network access type for accessing Log - Analytics ingestion. Possible values include: "Enabled", "Disabled". Default value: "Enabled". + Analytics ingestion. Known values are: "Enabled", "Disabled". Default value: "Enabled". :paramtype public_network_access_for_ingestion: str or ~azure.mgmt.loganalytics.models.PublicNetworkAccessType :keyword public_network_access_for_query: The network access type for accessing Log Analytics - query. Possible values include: "Enabled", "Disabled". Default value: "Enabled". + query. Known values are: "Enabled", "Disabled". Default value: "Enabled". :paramtype public_network_access_for_query: str or ~azure.mgmt.loganalytics.models.PublicNetworkAccessType :keyword force_cmk_for_query: Indicates whether customer managed storage is mandatory for query @@ -3673,8 +3669,8 @@ class WorkspaceCapping(msrest.serialization.Model): :vartype daily_quota_gb: float :ivar quota_next_reset_time: The time when the quota will be rest. :vartype quota_next_reset_time: str - :ivar data_ingestion_status: The status of data ingestion for this workspace. Possible values - include: "RespectQuota", "ForceOn", "ForceOff", "OverQuota", "SubscriptionSuspended", + :ivar data_ingestion_status: The status of data ingestion for this workspace. Known values are: + "RespectQuota", "ForceOn", "ForceOff", "OverQuota", "SubscriptionSuspended", "ApproachingQuota". :vartype data_ingestion_status: str or ~azure.mgmt.loganalytics.models.DataIngestionStatus """ @@ -3786,7 +3782,7 @@ class WorkspaceListManagementGroupsResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ManagementGroup"]] = None, + value: Optional[List["_models.ManagementGroup"]] = None, **kwargs ): """ @@ -3811,7 +3807,7 @@ class WorkspaceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Workspace"]] = None, + value: Optional[List["_models.Workspace"]] = None, **kwargs ): """ @@ -3836,7 +3832,7 @@ class WorkspaceListUsagesResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["UsageMetric"]] = None, + value: Optional[List["_models.UsageMetric"]] = None, **kwargs ): """ @@ -3864,7 +3860,7 @@ class WorkspacePatch(AzureEntityResource): :vartype etag: str :ivar tags: A set of tags. Resource tags. Optional. :vartype tags: dict[str, str] - :ivar provisioning_state: The provisioning state of the workspace. Possible values include: + :ivar provisioning_state: The provisioning state of the workspace. Known values are: "Creating", "Succeeded", "Failed", "Canceled", "Deleting", "ProvisioningAccount", "Updating". :vartype provisioning_state: str or ~azure.mgmt.loganalytics.models.WorkspaceEntityStatus :ivar customer_id: This is a read-only property. Represents the ID associated with the @@ -3882,11 +3878,11 @@ class WorkspacePatch(AzureEntityResource): :ivar modified_date: Workspace modification date. :vartype modified_date: str :ivar public_network_access_for_ingestion: The network access type for accessing Log Analytics - ingestion. Possible values include: "Enabled", "Disabled". Default value: "Enabled". + ingestion. Known values are: "Enabled", "Disabled". Default value: "Enabled". :vartype public_network_access_for_ingestion: str or ~azure.mgmt.loganalytics.models.PublicNetworkAccessType :ivar public_network_access_for_query: The network access type for accessing Log Analytics - query. Possible values include: "Enabled", "Disabled". Default value: "Enabled". + query. Known values are: "Enabled", "Disabled". Default value: "Enabled". :vartype public_network_access_for_query: str or ~azure.mgmt.loganalytics.models.PublicNetworkAccessType :ivar force_cmk_for_query: Indicates whether customer managed storage is mandatory for query @@ -3940,13 +3936,13 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["WorkspaceSku"] = None, + sku: Optional["_models.WorkspaceSku"] = None, retention_in_days: Optional[int] = None, - workspace_capping: Optional["WorkspaceCapping"] = None, - public_network_access_for_ingestion: Optional[Union[str, "PublicNetworkAccessType"]] = "Enabled", - public_network_access_for_query: Optional[Union[str, "PublicNetworkAccessType"]] = "Enabled", + workspace_capping: Optional["_models.WorkspaceCapping"] = None, + public_network_access_for_ingestion: Optional[Union[str, "_models.PublicNetworkAccessType"]] = "Enabled", + public_network_access_for_query: Optional[Union[str, "_models.PublicNetworkAccessType"]] = "Enabled", force_cmk_for_query: Optional[bool] = None, - features: Optional["WorkspaceFeatures"] = None, + features: Optional["_models.WorkspaceFeatures"] = None, default_data_collection_rule_resource_id: Optional[str] = None, **kwargs ): @@ -3961,11 +3957,11 @@ def __init__( :keyword workspace_capping: The daily volume cap for ingestion. :paramtype workspace_capping: ~azure.mgmt.loganalytics.models.WorkspaceCapping :keyword public_network_access_for_ingestion: The network access type for accessing Log - Analytics ingestion. Possible values include: "Enabled", "Disabled". Default value: "Enabled". + Analytics ingestion. Known values are: "Enabled", "Disabled". Default value: "Enabled". :paramtype public_network_access_for_ingestion: str or ~azure.mgmt.loganalytics.models.PublicNetworkAccessType :keyword public_network_access_for_query: The network access type for accessing Log Analytics - query. Possible values include: "Enabled", "Disabled". Default value: "Enabled". + query. Known values are: "Enabled", "Disabled". Default value: "Enabled". :paramtype public_network_access_for_query: str or ~azure.mgmt.loganalytics.models.PublicNetworkAccessType :keyword force_cmk_for_query: Indicates whether customer managed storage is mandatory for query @@ -4021,7 +4017,7 @@ def __init__( self, *, table: str, - filters: List["WorkspacePurgeBodyFilters"], + filters: List["_models.WorkspacePurgeBodyFilters"], **kwargs ): """ @@ -4128,8 +4124,8 @@ class WorkspacePurgeStatusResponse(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar status: Required. Status of the operation represented by the requested Id. Possible - values include: "pending", "completed". + :ivar status: Required. Status of the operation represented by the requested Id. Known values + are: "pending", "completed". :vartype status: str or ~azure.mgmt.loganalytics.models.PurgeState """ @@ -4144,12 +4140,12 @@ class WorkspacePurgeStatusResponse(msrest.serialization.Model): def __init__( self, *, - status: Union[str, "PurgeState"], + status: Union[str, "_models.PurgeState"], **kwargs ): """ - :keyword status: Required. Status of the operation represented by the requested Id. Possible - values include: "pending", "completed". + :keyword status: Required. Status of the operation represented by the requested Id. Known + values are: "pending", "completed". :paramtype status: str or ~azure.mgmt.loganalytics.models.PurgeState """ super(WorkspacePurgeStatusResponse, self).__init__(**kwargs) @@ -4163,12 +4159,12 @@ class WorkspaceSku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the SKU. Possible values include: "Free", "Standard", - "Premium", "PerNode", "PerGB2018", "Standalone", "CapacityReservation", "LACluster". + :ivar name: Required. The name of the SKU. Known values are: "Free", "Standard", "Premium", + "PerNode", "PerGB2018", "Standalone", "CapacityReservation", "LACluster". :vartype name: str or ~azure.mgmt.loganalytics.models.WorkspaceSkuNameEnum :ivar capacity_reservation_level: The capacity reservation level in GB for this workspace, when - CapacityReservation sku is selected. Possible values include: 100, 200, 300, 400, 500, 1000, - 2000, 5000. + CapacityReservation sku is selected. Known values are: 100, 200, 300, 400, 500, 1000, 2000, + 5000. :vartype capacity_reservation_level: int or ~azure.mgmt.loganalytics.models.CapacityReservationLevel :ivar last_sku_update: The last time when the sku was updated. @@ -4189,17 +4185,17 @@ class WorkspaceSku(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "WorkspaceSkuNameEnum"], - capacity_reservation_level: Optional[Union[int, "CapacityReservationLevel"]] = None, + name: Union[str, "_models.WorkspaceSkuNameEnum"], + capacity_reservation_level: Optional[Union[int, "_models.CapacityReservationLevel"]] = None, **kwargs ): """ - :keyword name: Required. The name of the SKU. Possible values include: "Free", "Standard", - "Premium", "PerNode", "PerGB2018", "Standalone", "CapacityReservation", "LACluster". + :keyword name: Required. The name of the SKU. Known values are: "Free", "Standard", "Premium", + "PerNode", "PerGB2018", "Standalone", "CapacityReservation", "LACluster". :paramtype name: str or ~azure.mgmt.loganalytics.models.WorkspaceSkuNameEnum :keyword capacity_reservation_level: The capacity reservation level in GB for this workspace, - when CapacityReservation sku is selected. Possible values include: 100, 200, 300, 400, 500, - 1000, 2000, 5000. + when CapacityReservation sku is selected. Known values are: 100, 200, 300, 400, 500, 1000, + 2000, 5000. :paramtype capacity_reservation_level: int or ~azure.mgmt.loganalytics.models.CapacityReservationLevel """ diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_patch.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/__init__.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/__init__.py index 72e307c7d6e6..09f82c9f74e2 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/__init__.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/__init__.py @@ -29,6 +29,9 @@ from ._deleted_workspaces_operations import DeletedWorkspacesOperations from ._tables_operations import TablesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'QueryPacksOperations', 'QueriesOperations', @@ -53,3 +56,5 @@ 'DeletedWorkspacesOperations', 'TablesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_available_service_tiers_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_available_service_tiers_operations.py index 2b27e239ff10..52af65b5dcdd 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_available_service_tiers_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_available_service_tiers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, List, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,55 +32,55 @@ def build_list_by_workspace_request( workspace_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/availableServiceTiers') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/availableServiceTiers") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class AvailableServiceTiersOperations(object): - """AvailableServiceTiersOperations 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. +class AvailableServiceTiersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.LogAnalyticsManagementClient`'s + :attr:`available_service_tiers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_workspace( @@ -87,35 +88,50 @@ def list_by_workspace( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> List["_models.AvailableServiceTier"]: + ) -> List[_models.AvailableServiceTier]: """Gets the available service tiers for the workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: list of AvailableServiceTier, or the result of cls(response) :rtype: list[~azure.mgmt.loganalytics.models.AvailableServiceTier] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.AvailableServiceTier"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.AvailableServiceTier]] request = build_list_by_workspace_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + api_version=api_version, template_url=self.list_by_workspace.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -129,5 +145,5 @@ def list_by_workspace( return deserialized - list_by_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/availableServiceTiers'} # type: ignore + list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/availableServiceTiers"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_clusters_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_clusters_operations.py index 71e7fc93be24..9068bfbcb7f0 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_clusters_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_clusters_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -34,30 +34,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,29 +68,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/clusters') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/clusters") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -98,39 +102,40 @@ def build_create_or_update_request_initial( subscription_id: str, cluster_name: str, *, - json: JSONType = None, + json: Optional[_models.Cluster] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -143,31 +148,33 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -178,31 +185,33 @@ def build_get_request( cluster_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -212,106 +221,119 @@ def build_update_request_initial( cluster_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ClusterPatch] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class ClustersOperations(object): - """ClustersOperations 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. +class ClustersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.LogAnalyticsManagementClient`'s + :attr:`clusters` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ClusterListResult"]: + ) -> Iterable[_models.ClusterListResult]: """Gets Log Analytics clusters in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str + :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ClusterListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.loganalytics.models.ClusterListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ClusterListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -325,7 +347,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -339,43 +365,57 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.ClusterListResult"]: + ) -> Iterable[_models.ClusterListResult]: """Gets the Log Analytics clusters in a subscription. + :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ClusterListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.loganalytics.models.ClusterListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ClusterListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -389,7 +429,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -403,22 +447,26 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/clusters'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/clusters"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, - parameters: "_models.Cluster", + parameters: _models.Cluster, **kwargs: Any - ) -> Optional["_models.Cluster"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Cluster"]] + ) -> Optional[_models.Cluster]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Cluster]] _json = self._serialize.body(parameters, 'Cluster') @@ -426,14 +474,21 @@ def _create_or_update_initial( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, cluster_name=cluster_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -452,7 +507,7 @@ def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}"} # type: ignore @distributed_trace @@ -460,9 +515,9 @@ def begin_create_or_update( self, resource_group_name: str, cluster_name: str, - parameters: "_models.Cluster", + parameters: _models.Cluster, **kwargs: Any - ) -> LROPoller["_models.Cluster"]: + ) -> LROPoller[_models.Cluster]: """Create or update a Log Analytics cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -471,6 +526,9 @@ def begin_create_or_update( :type cluster_name: str :param parameters: The parameters required to create or update a Log Analytics cluster. :type parameters: ~azure.mgmt.loganalytics.models.Cluster + :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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 @@ -483,35 +541,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.loganalytics.models.Cluster] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Cluster] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] 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( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('Cluster', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -520,34 +590,45 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}"} # type: ignore - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -557,11 +638,11 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}"} # type: ignore @distributed_trace - def begin_delete( + def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, @@ -573,6 +654,9 @@ def begin_delete( :type resource_group_name: str :param cluster_name: Name of the Log Analytics Cluster. :type cluster_name: str + :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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 @@ -585,18 +669,25 @@ def begin_delete( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] 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( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -606,8 +697,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -616,10 +713,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}"} # type: ignore @distributed_trace def get( @@ -627,35 +723,50 @@ def get( resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> "_models.Cluster": + ) -> _models.Cluster: """Gets a Log Analytics cluster instance. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param cluster_name: Name of the Log Analytics Cluster. :type cluster_name: str + :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Cluster, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.Cluster :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Cluster] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -670,23 +781,27 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}"} # type: ignore def _update_initial( self, resource_group_name: str, cluster_name: str, - parameters: "_models.ClusterPatch", + parameters: _models.ClusterPatch, **kwargs: Any - ) -> "_models.Cluster": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] + ) -> _models.Cluster: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Cluster] _json = self._serialize.body(parameters, 'ClusterPatch') @@ -694,14 +809,21 @@ def _update_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -715,7 +837,7 @@ def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}"} # type: ignore @distributed_trace @@ -723,9 +845,9 @@ def begin_update( self, resource_group_name: str, cluster_name: str, - parameters: "_models.ClusterPatch", + parameters: _models.ClusterPatch, **kwargs: Any - ) -> LROPoller["_models.Cluster"]: + ) -> LROPoller[_models.Cluster]: """Updates a Log Analytics cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -734,6 +856,9 @@ def begin_update( :type cluster_name: str :param parameters: The parameters required to patch a Log Analytics cluster. :type parameters: ~azure.mgmt.loganalytics.models.ClusterPatch + :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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 @@ -746,35 +871,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.loganalytics.models.Cluster] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Cluster] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] 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._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('Cluster', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -783,7 +920,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_data_exports_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_data_exports_operations.py index 2364fc9878f1..bb44324ba089 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_data_exports_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_data_exports_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_by_workspace_request( workspace_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -68,16 +70,19 @@ def build_create_or_update_request( workspace_name: str, data_export_name: str, *, - json: JSONType = None, + json: Optional[_models.DataExport] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports/{dataExportName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports/{dataExportName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -85,23 +90,21 @@ def build_create_or_update_request( "dataExportName": _SERIALIZER.url("data_export_name", data_export_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z][A-Za-z0-9-]+[A-Za-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -115,10 +118,14 @@ def build_get_request( data_export_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports/{dataExportName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports/{dataExportName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -126,21 +133,19 @@ def build_get_request( "dataExportName": _SERIALIZER.url("data_export_name", data_export_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -152,10 +157,14 @@ def build_delete_request( data_export_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports/{dataExportName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports/{dataExportName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -163,45 +172,41 @@ def build_delete_request( "dataExportName": _SERIALIZER.url("data_export_name", data_export_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DataExportsOperations(object): - """DataExportsOperations 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. +class DataExportsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.LogAnalyticsManagementClient`'s + :attr:`data_exports` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_workspace( @@ -209,24 +214,32 @@ def list_by_workspace( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> Iterable["_models.DataExportListResult"]: + ) -> Iterable[_models.DataExportListResult]: """Lists the data export instances within a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DataExportListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.loganalytics.models.DataExportListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataExportListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataExportListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -234,10 +247,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + api_version=api_version, template_url=self.list_by_workspace.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -245,10 +261,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -262,7 +281,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -276,7 +299,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports'} # type: ignore + list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports"} # type: ignore @distributed_trace def create_or_update( @@ -284,9 +307,9 @@ def create_or_update( resource_group_name: str, workspace_name: str, data_export_name: str, - parameters: "_models.DataExport", + parameters: _models.DataExport, **kwargs: Any - ) -> "_models.DataExport": + ) -> _models.DataExport: """Create or update a data export. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -297,18 +320,25 @@ def create_or_update( :type data_export_name: str :param parameters: The parameters required to create or update a data export. :type parameters: ~azure.mgmt.loganalytics.models.DataExport + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DataExport, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.DataExport :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataExport"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataExport] _json = self._serialize.body(parameters, 'DataExport') @@ -317,14 +347,21 @@ def create_or_update( resource_group_name=resource_group_name, workspace_name=workspace_name, data_export_name=data_export_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -343,7 +380,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports/{dataExportName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports/{dataExportName}"} # type: ignore @distributed_trace @@ -353,7 +390,7 @@ def get( workspace_name: str, data_export_name: str, **kwargs: Any - ) -> "_models.DataExport": + ) -> _models.DataExport: """Gets a data export instance. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -362,16 +399,24 @@ def get( :type workspace_name: str :param data_export_name: The data export rule name. :type data_export_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DataExport, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.DataExport :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataExport"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataExport] request = build_get_request( @@ -379,12 +424,19 @@ def get( resource_group_name=resource_group_name, workspace_name=workspace_name, data_export_name=data_export_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -399,11 +451,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports/{dataExportName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports/{dataExportName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, @@ -418,16 +470,24 @@ def delete( :type workspace_name: str :param data_export_name: The data export rule name. :type data_export_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -435,12 +495,19 @@ def delete( resource_group_name=resource_group_name, workspace_name=workspace_name, data_export_name=data_export_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 404]: @@ -451,5 +518,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports/{dataExportName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports/{dataExportName}"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_data_sources_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_data_sources_operations.py index 460d7b9148ad..b193120600fe 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_data_sources_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_data_sources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,16 +33,19 @@ def build_create_or_update_request( data_source_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DataSource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources/{dataSourceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources/{dataSourceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), @@ -50,23 +53,21 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,9 +81,11 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources/{dataSourceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources/{dataSourceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), @@ -90,16 +93,15 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -111,10 +113,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources/{dataSourceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources/{dataSourceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), @@ -122,21 +128,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -150,58 +154,58 @@ def build_list_by_workspace_request( skiptoken: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if skiptoken is not None: - query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DataSourcesOperations(object): - """DataSourcesOperations 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. +class DataSourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.LogAnalyticsManagementClient`'s + :attr:`data_sources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create_or_update( @@ -209,9 +213,9 @@ def create_or_update( resource_group_name: str, workspace_name: str, data_source_name: str, - parameters: "_models.DataSource", + parameters: _models.DataSource, **kwargs: Any - ) -> "_models.DataSource": + ) -> _models.DataSource: """Create or update a data source. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -222,18 +226,25 @@ def create_or_update( :type data_source_name: str :param parameters: The parameters required to create or update a datasource. :type parameters: ~azure.mgmt.loganalytics.models.DataSource + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DataSource, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.DataSource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataSource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataSource] _json = self._serialize.body(parameters, 'DataSource') @@ -242,14 +253,21 @@ def create_or_update( workspace_name=workspace_name, data_source_name=data_source_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -267,11 +285,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources/{dataSourceName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources/{dataSourceName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, @@ -286,16 +304,24 @@ def delete( :type workspace_name: str :param data_source_name: Name of the datasource. :type data_source_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -303,12 +329,19 @@ def delete( workspace_name=workspace_name, data_source_name=data_source_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -318,7 +351,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources/{dataSourceName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources/{dataSourceName}"} # type: ignore @distributed_trace @@ -328,7 +361,7 @@ def get( workspace_name: str, data_source_name: str, **kwargs: Any - ) -> "_models.DataSource": + ) -> _models.DataSource: """Gets a datasource instance. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -337,16 +370,24 @@ def get( :type workspace_name: str :param data_source_name: Name of the datasource. :type data_source_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DataSource, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.DataSource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataSource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataSource] request = build_get_request( @@ -354,12 +395,19 @@ def get( workspace_name=workspace_name, data_source_name=data_source_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -373,7 +421,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources/{dataSourceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources/{dataSourceName}"} # type: ignore @distributed_trace @@ -384,7 +432,7 @@ def list_by_workspace( filter: str, skiptoken: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.DataSourceListResult"]: + ) -> Iterable[_models.DataSourceListResult]: """Gets the first page of data source instances in a workspace with the link to the next page. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -393,19 +441,28 @@ def list_by_workspace( :type workspace_name: str :param filter: The filter to apply on the operation. :type filter: str - :param skiptoken: Starting point of the collection of data source instances. + :param skiptoken: Starting point of the collection of data source instances. Default value is + None. :type skiptoken: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DataSourceListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.loganalytics.models.DataSourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataSourceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataSourceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -413,12 +470,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, skiptoken=skiptoken, template_url=self.list_by_workspace.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -426,12 +486,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, skiptoken=skiptoken, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -445,7 +508,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -458,4 +525,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources'} # type: ignore + list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_deleted_workspaces_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_deleted_workspaces_operations.py index 24373c0a0d9f..5917478b3ac0 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_deleted_workspaces_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_deleted_workspaces_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,29 +31,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-12-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/deletedWorkspaces') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/deletedWorkspaces") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -62,90 +65,104 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-12-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/deletedWorkspaces') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/deletedWorkspaces") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DeletedWorkspacesOperations(object): - """DeletedWorkspacesOperations 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. +class DeletedWorkspacesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.LogAnalyticsManagementClient`'s + :attr:`deleted_workspaces` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.WorkspaceListResult"]: + ) -> Iterable[_models.WorkspaceListResult]: """Gets recently deleted workspaces in a subscription, available for recovery. + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkspaceListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.loganalytics.models.WorkspaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspaceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -159,7 +176,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -173,48 +194,62 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/deletedWorkspaces'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/deletedWorkspaces"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.WorkspaceListResult"]: + ) -> Iterable[_models.WorkspaceListResult]: """Gets recently deleted workspaces in a resource group, available for recovery. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkspaceListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.loganalytics.models.WorkspaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspaceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -228,7 +263,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -242,4 +281,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/deletedWorkspaces'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/deletedWorkspaces"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_gateways_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_gateways_operations.py index 44b02b4ab2b6..36b3395ae0f6 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_gateways_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_gateways_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -32,9 +33,11 @@ def build_delete_request( gateway_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/gateways/{gatewayId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/gateways/{gatewayId}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -42,43 +45,40 @@ def build_delete_request( "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) -class GatewaysOperations(object): - """GatewaysOperations 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. +class GatewaysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.LogAnalyticsManagementClient`'s + :attr:`gateways` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, @@ -93,16 +93,24 @@ def delete( :type workspace_name: str :param gateway_id: The Log Analytics gateway Id. :type gateway_id: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -110,12 +118,19 @@ def delete( resource_group_name=resource_group_name, workspace_name=workspace_name, gateway_id=gateway_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -125,5 +140,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/gateways/{gatewayId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/gateways/{gatewayId}"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_intelligence_packs_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_intelligence_packs_operations.py index bf3c5129281b..a1d133f4519a 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_intelligence_packs_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_intelligence_packs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, List, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -32,9 +33,11 @@ def build_disable_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/intelligencePacks/{intelligencePackName}/Disable') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/intelligencePacks/{intelligencePackName}/Disable") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), @@ -42,16 +45,15 @@ def build_disable_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -63,9 +65,11 @@ def build_enable_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/intelligencePacks/{intelligencePackName}/Enable') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/intelligencePacks/{intelligencePackName}/Enable") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), @@ -73,16 +77,15 @@ def build_enable_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -93,58 +96,58 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/intelligencePacks') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/intelligencePacks") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class IntelligencePacksOperations(object): - """IntelligencePacksOperations 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. +class IntelligencePacksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.LogAnalyticsManagementClient`'s + :attr:`intelligence_packs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace - def disable( + def disable( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, @@ -159,16 +162,24 @@ def disable( :type workspace_name: str :param intelligence_pack_name: The name of the intelligence pack to be disabled. :type intelligence_pack_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_disable_request( @@ -176,12 +187,19 @@ def disable( workspace_name=workspace_name, intelligence_pack_name=intelligence_pack_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.disable.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -191,11 +209,11 @@ def disable( if cls: return cls(pipeline_response, None, {}) - disable.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/intelligencePacks/{intelligencePackName}/Disable'} # type: ignore + disable.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/intelligencePacks/{intelligencePackName}/Disable"} # type: ignore @distributed_trace - def enable( + def enable( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, @@ -210,16 +228,24 @@ def enable( :type workspace_name: str :param intelligence_pack_name: The name of the intelligence pack to be enabled. :type intelligence_pack_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_enable_request( @@ -227,12 +253,19 @@ def enable( workspace_name=workspace_name, intelligence_pack_name=intelligence_pack_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.enable.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -242,7 +275,7 @@ def enable( if cls: return cls(pipeline_response, None, {}) - enable.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/intelligencePacks/{intelligencePackName}/Enable'} # type: ignore + enable.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/intelligencePacks/{intelligencePackName}/Enable"} # type: ignore @distributed_trace @@ -251,7 +284,7 @@ def list( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> List["_models.IntelligencePack"]: + ) -> List[_models.IntelligencePack]: """Lists all the intelligence packs possible and whether they are enabled or disabled for a given workspace. @@ -259,28 +292,43 @@ def list( :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: list of IntelligencePack, or the result of cls(response) :rtype: list[~azure.mgmt.loganalytics.models.IntelligencePack] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.IntelligencePack"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.IntelligencePack]] request = build_list_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -294,5 +342,5 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/intelligencePacks'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/intelligencePacks"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_linked_services_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_linked_services_operations.py index cce186c1e694..43818542039d 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_linked_services_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_linked_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -35,16 +35,19 @@ def build_create_or_update_request_initial( linked_service_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LinkedService] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), @@ -52,23 +55,21 @@ def build_create_or_update_request_initial( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -82,10 +83,14 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), @@ -93,21 +98,19 @@ def build_delete_request_initial( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -119,10 +122,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), @@ -130,21 +137,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -155,71 +160,75 @@ def build_list_by_workspace_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class LinkedServicesOperations(object): - """LinkedServicesOperations 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. +class LinkedServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.LogAnalyticsManagementClient`'s + :attr:`linked_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, linked_service_name: str, - parameters: "_models.LinkedService", + parameters: _models.LinkedService, **kwargs: Any - ) -> Optional["_models.LinkedService"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LinkedService"]] + ) -> Optional[_models.LinkedService]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.LinkedService]] _json = self._serialize.body(parameters, 'LinkedService') @@ -228,14 +237,21 @@ def _create_or_update_initial( workspace_name=workspace_name, linked_service_name=linked_service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -254,7 +270,7 @@ def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}"} # type: ignore @distributed_trace @@ -263,9 +279,9 @@ def begin_create_or_update( resource_group_name: str, workspace_name: str, linked_service_name: str, - parameters: "_models.LinkedService", + parameters: _models.LinkedService, **kwargs: Any - ) -> LROPoller["_models.LinkedService"]: + ) -> LROPoller[_models.LinkedService]: """Create or update a linked service. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -276,6 +292,9 @@ def begin_create_or_update( :type linked_service_name: str :param parameters: The parameters required to create or update a linked service. :type parameters: ~azure.mgmt.loganalytics.models.LinkedService + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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 @@ -289,36 +308,48 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.loganalytics.models.LinkedService] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkedService"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LinkedService] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] 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( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, linked_service_name=linked_service_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('LinkedService', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -327,10 +358,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}"} # type: ignore def _delete_initial( self, @@ -338,12 +368,17 @@ def _delete_initial( workspace_name: str, linked_service_name: str, **kwargs: Any - ) -> Optional["_models.LinkedService"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LinkedService"]] + ) -> Optional[_models.LinkedService]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.LinkedService]] request = build_delete_request_initial( @@ -351,12 +386,19 @@ def _delete_initial( workspace_name=workspace_name, linked_service_name=linked_service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -372,7 +414,7 @@ def _delete_initial( return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}"} # type: ignore @distributed_trace @@ -382,7 +424,7 @@ def begin_delete( workspace_name: str, linked_service_name: str, **kwargs: Any - ) -> LROPoller["_models.LinkedService"]: + ) -> LROPoller[_models.LinkedService]: """Deletes a linked service instance. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -391,6 +433,9 @@ def begin_delete( :type workspace_name: str :param linked_service_name: Name of the linked service. :type linked_service_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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 @@ -404,33 +449,45 @@ def begin_delete( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.loganalytics.models.LinkedService] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkedService"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LinkedService] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] 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( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, linked_service_name=linked_service_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('LinkedService', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -439,10 +496,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}"} # type: ignore @distributed_trace def get( @@ -451,7 +507,7 @@ def get( workspace_name: str, linked_service_name: str, **kwargs: Any - ) -> "_models.LinkedService": + ) -> _models.LinkedService: """Gets a linked service instance. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -460,16 +516,24 @@ def get( :type workspace_name: str :param linked_service_name: Name of the linked service. :type linked_service_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LinkedService, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.LinkedService :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkedService"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LinkedService] request = build_get_request( @@ -477,12 +541,19 @@ def get( workspace_name=workspace_name, linked_service_name=linked_service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -496,7 +567,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}"} # type: ignore @distributed_trace @@ -505,24 +576,32 @@ def list_by_workspace( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> Iterable["_models.LinkedServiceListResult"]: + ) -> Iterable[_models.LinkedServiceListResult]: """Gets the linked services instances in a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LinkedServiceListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.loganalytics.models.LinkedServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkedServiceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LinkedServiceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -530,10 +609,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_workspace.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -541,10 +623,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -558,7 +643,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -571,4 +660,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices'} # type: ignore + list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_linked_storage_accounts_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_linked_storage_accounts_operations.py index 9b4654d6b88e..13a076573007 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_linked_storage_accounts_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_linked_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,16 +33,19 @@ def build_create_or_update_request( data_source_type: Union[str, "_models.DataSourceType"], subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LinkedStorageAccountsResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts/{dataSourceType}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts/{dataSourceType}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), @@ -50,23 +53,21 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,9 +81,11 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts/{dataSourceType}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts/{dataSourceType}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), @@ -90,16 +93,15 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -111,10 +113,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts/{dataSourceType}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts/{dataSourceType}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), @@ -122,21 +128,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -147,55 +151,55 @@ def build_list_by_workspace_request( workspace_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class LinkedStorageAccountsOperations(object): - """LinkedStorageAccountsOperations 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. +class LinkedStorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.LogAnalyticsManagementClient`'s + :attr:`linked_storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create_or_update( @@ -203,9 +207,9 @@ def create_or_update( resource_group_name: str, workspace_name: str, data_source_type: Union[str, "_models.DataSourceType"], - parameters: "_models.LinkedStorageAccountsResource", + parameters: _models.LinkedStorageAccountsResource, **kwargs: Any - ) -> "_models.LinkedStorageAccountsResource": + ) -> _models.LinkedStorageAccountsResource: """Create or Update a link relation between current workspace and a group of storage accounts of a specific data source type. @@ -217,18 +221,25 @@ def create_or_update( :type data_source_type: str or ~azure.mgmt.loganalytics.models.DataSourceType :param parameters: The parameters required to create or update linked storage accounts. :type parameters: ~azure.mgmt.loganalytics.models.LinkedStorageAccountsResource + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LinkedStorageAccountsResource, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.LinkedStorageAccountsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkedStorageAccountsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LinkedStorageAccountsResource] _json = self._serialize.body(parameters, 'LinkedStorageAccountsResource') @@ -237,14 +248,21 @@ def create_or_update( workspace_name=workspace_name, data_source_type=data_source_type, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -258,11 +276,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts/{dataSourceType}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts/{dataSourceType}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, @@ -278,16 +296,24 @@ def delete( :type workspace_name: str :param data_source_type: Linked storage accounts type. :type data_source_type: str or ~azure.mgmt.loganalytics.models.DataSourceType + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -295,12 +321,19 @@ def delete( workspace_name=workspace_name, data_source_type=data_source_type, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -310,7 +343,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts/{dataSourceType}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts/{dataSourceType}"} # type: ignore @distributed_trace @@ -320,7 +353,7 @@ def get( workspace_name: str, data_source_type: Union[str, "_models.DataSourceType"], **kwargs: Any - ) -> "_models.LinkedStorageAccountsResource": + ) -> _models.LinkedStorageAccountsResource: """Gets all linked storage account of a specific data source type associated with the specified workspace. @@ -330,16 +363,24 @@ def get( :type workspace_name: str :param data_source_type: Linked storage accounts type. :type data_source_type: str or ~azure.mgmt.loganalytics.models.DataSourceType + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LinkedStorageAccountsResource, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.LinkedStorageAccountsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkedStorageAccountsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LinkedStorageAccountsResource] request = build_get_request( @@ -347,12 +388,19 @@ def get( workspace_name=workspace_name, data_source_type=data_source_type, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -366,7 +414,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts/{dataSourceType}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts/{dataSourceType}"} # type: ignore @distributed_trace @@ -375,7 +423,7 @@ def list_by_workspace( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> Iterable["_models.LinkedStorageAccountsListResult"]: + ) -> Iterable[_models.LinkedStorageAccountsListResult]: """Gets all linked storage accounts associated with the specified workspace, storage accounts will be sorted by their data source type. @@ -383,6 +431,9 @@ def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LinkedStorageAccountsListResult or the result of cls(response) @@ -390,11 +441,16 @@ def list_by_workspace( ~azure.core.paging.ItemPaged[~azure.mgmt.loganalytics.models.LinkedStorageAccountsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkedStorageAccountsListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LinkedStorageAccountsListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -402,10 +458,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + api_version=api_version, template_url=self.list_by_workspace.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -413,10 +472,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -430,7 +492,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -443,4 +509,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts'} # type: ignore + list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_management_groups_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_management_groups_operations.py index 072394582c52..01cd4a3bd38d 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_management_groups_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_management_groups_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -32,55 +33,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/managementGroups') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/managementGroups") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ManagementGroupsOperations(object): - """ManagementGroupsOperations 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. +class ManagementGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.LogAnalyticsManagementClient`'s + :attr:`management_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -88,13 +89,16 @@ def list( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> Iterable["_models.WorkspaceListManagementGroupsResult"]: + ) -> Iterable[_models.WorkspaceListManagementGroupsResult]: """Gets a list of management groups connected to a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkspaceListManagementGroupsResult or the result of cls(response) @@ -102,11 +106,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.loganalytics.models.WorkspaceListManagementGroupsResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceListManagementGroupsResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspaceListManagementGroupsResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -114,10 +123,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -125,10 +137,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -142,7 +157,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -155,4 +174,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/managementGroups'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/managementGroups"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_operation_statuses_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_operation_statuses_operations.py index 11cd5ce16b89..564e2f514657 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_operation_statuses_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_operation_statuses_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,55 +32,55 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/locations/{location}/operationStatuses/{asyncOperationId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/locations/{location}/operationStatuses/{asyncOperationId}") # pylint: disable=line-too-long path_format_arguments = { "location": _SERIALIZER.url("location", location, 'str'), "asyncOperationId": _SERIALIZER.url("async_operation_id", async_operation_id, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class OperationStatusesOperations(object): - """OperationStatusesOperations 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. +class OperationStatusesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.LogAnalyticsManagementClient`'s + :attr:`operation_statuses` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -87,35 +88,50 @@ def get( location: str, async_operation_id: str, **kwargs: Any - ) -> "_models.OperationStatus": + ) -> _models.OperationStatus: """Get the status of a long running azure asynchronous operation. :param location: The region name of operation. :type location: str :param async_operation_id: The operation Id. :type async_operation_id: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationStatus, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.OperationStatus :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatus"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatus] request = build_get_request( location=location, async_operation_id=async_operation_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -129,5 +145,5 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/locations/{location}/operationStatuses/{asyncOperationId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/locations/{location}/operationStatuses/{asyncOperationId}"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_operations.py index 68ee29ebe31c..c5c7259df298 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -29,82 +30,96 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2021-12-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.OperationalInsights/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.OperationalInsights/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -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. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.LogAnalyticsManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + ) -> Iterable[_models.OperationListResult]: """Lists all of the available OperationalInsights Rest API operations. + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :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[~azure.mgmt.loganalytics.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -118,7 +133,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,4 +151,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.OperationalInsights/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.OperationalInsights/operations"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_patch.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_queries_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_queries_operations.py index ab2bb81ddbb8..018bb9906f3b 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_queries_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_queries_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_request( skip_token: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2019-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "queryPackName": _SERIALIZER.url("query_pack_name", query_pack_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'long') + _params['$top'] = _SERIALIZER.query("top", top, 'long') if include_body is not None: - query_parameters['includeBody'] = _SERIALIZER.query("include_body", include_body, 'bool') + _params['includeBody'] = _SERIALIZER.query("include_body", include_body, 'bool') if skip_token is not None: - query_parameters['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') + _params['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -77,48 +79,49 @@ def build_search_request( resource_group_name: str, query_pack_name: str, *, - json: JSONType = None, + json: Optional[_models.LogAnalyticsQueryPackQuerySearchProperties] = None, content: Any = None, top: Optional[int] = None, include_body: Optional[bool] = None, skip_token: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/search') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/search") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "queryPackName": _SERIALIZER.url("query_pack_name", query_pack_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'long') + _params['$top'] = _SERIALIZER.query("top", top, 'long') if include_body is not None: - query_parameters['includeBody'] = _SERIALIZER.query("include_body", include_body, 'bool') + _params['includeBody'] = _SERIALIZER.query("include_body", include_body, 'bool') if skip_token is not None: - query_parameters['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') + _params['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -132,10 +135,14 @@ def build_get_request( id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -143,21 +150,19 @@ def build_get_request( "id": _SERIALIZER.url("id", id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -168,16 +173,19 @@ def build_put_request( query_pack_name: str, id: str, *, - json: JSONType = None, + json: Optional[_models.LogAnalyticsQueryPackQuery] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -185,23 +193,21 @@ def build_put_request( "id": _SERIALIZER.url("id", id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -214,16 +220,19 @@ def build_update_request( query_pack_name: str, id: str, *, - json: JSONType = None, + json: Optional[_models.LogAnalyticsQueryPackQuery] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -231,23 +240,21 @@ def build_update_request( "id": _SERIALIZER.url("id", id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -261,10 +268,14 @@ def build_delete_request( id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -272,45 +283,41 @@ def build_delete_request( "id": _SERIALIZER.url("id", id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class QueriesOperations(object): - """QueriesOperations 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. +class QueriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.LogAnalyticsManagementClient`'s + :attr:`queries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -321,20 +328,23 @@ def list( include_body: Optional[bool] = None, skip_token: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.LogAnalyticsQueryPackQueryListResult"]: + ) -> Iterable[_models.LogAnalyticsQueryPackQueryListResult]: """Gets a list of Queries defined within a Log Analytics QueryPack. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param query_pack_name: The name of the Log Analytics QueryPack resource. :type query_pack_name: str - :param top: Maximum items returned in page. + :param top: Maximum items returned in page. Default value is None. :type top: long :param include_body: Flag indicating whether or not to return the body of each applicable - query. If false, only return the query information. + query. If false, only return the query information. Default value is None. :type include_body: bool :param skip_token: Base64 encoded token used to fetch the next page of items. Default is null. :type skip_token: str + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LogAnalyticsQueryPackQueryListResult or the result of cls(response) @@ -342,11 +352,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQueryListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackQueryListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsQueryPackQueryListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -354,13 +369,16 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, query_pack_name=query_pack_name, + api_version=api_version, top=top, include_body=include_body, skip_token=skip_token, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -368,13 +386,16 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, query_pack_name=query_pack_name, + api_version=api_version, top=top, include_body=include_body, skip_token=skip_token, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -388,7 +409,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -402,19 +427,19 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries"} # type: ignore @distributed_trace def search( self, resource_group_name: str, query_pack_name: str, - query_search_properties: "_models.LogAnalyticsQueryPackQuerySearchProperties", + query_search_properties: _models.LogAnalyticsQueryPackQuerySearchProperties, top: Optional[int] = None, include_body: Optional[bool] = None, skip_token: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.LogAnalyticsQueryPackQueryListResult"]: + ) -> Iterable[_models.LogAnalyticsQueryPackQueryListResult]: """Search a list of Queries defined within a Log Analytics QueryPack according to given search properties. @@ -426,13 +451,16 @@ def search( Analytics QueryPack. :type query_search_properties: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuerySearchProperties - :param top: Maximum items returned in page. + :param top: Maximum items returned in page. Default value is None. :type top: long :param include_body: Flag indicating whether or not to return the body of each applicable - query. If false, only return the query information. + query. If false, only return the query information. Default value is None. :type include_body: bool :param skip_token: Base64 encoded token used to fetch the next page of items. Default is null. :type skip_token: str + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LogAnalyticsQueryPackQueryListResult or the result of cls(response) @@ -440,13 +468,17 @@ def search( ~azure.core.paging.ItemPaged[~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQueryListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsQueryPackQueryListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackQueryListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: _json = self._serialize.body(query_search_properties, 'LogAnalyticsQueryPackQuerySearchProperties') @@ -455,15 +487,18 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, query_pack_name=query_pack_name, + api_version=api_version, content_type=content_type, json=_json, top=top, include_body=include_body, skip_token=skip_token, template_url=self.search.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: _json = self._serialize.body(query_search_properties, 'LogAnalyticsQueryPackQuerySearchProperties') @@ -472,15 +507,18 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, query_pack_name=query_pack_name, + api_version=api_version, content_type=content_type, json=_json, top=top, include_body=include_body, skip_token=skip_token, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -494,7 +532,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -508,7 +550,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - search.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/search'} # type: ignore + search.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/search"} # type: ignore @distributed_trace def get( @@ -517,7 +559,7 @@ def get( query_pack_name: str, id: str, **kwargs: Any - ) -> "_models.LogAnalyticsQueryPackQuery": + ) -> _models.LogAnalyticsQueryPackQuery: """Gets a specific Log Analytics Query defined within a Log Analytics QueryPack. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -526,16 +568,24 @@ def get( :type query_pack_name: str :param id: The id of a specific query defined in the Log Analytics QueryPack. :type id: str + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LogAnalyticsQueryPackQuery, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackQuery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsQueryPackQuery] request = build_get_request( @@ -543,12 +593,19 @@ def get( resource_group_name=resource_group_name, query_pack_name=query_pack_name, id=id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -563,7 +620,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}"} # type: ignore @distributed_trace @@ -572,9 +629,9 @@ def put( resource_group_name: str, query_pack_name: str, id: str, - query_payload: "_models.LogAnalyticsQueryPackQuery", + query_payload: _models.LogAnalyticsQueryPackQuery, **kwargs: Any - ) -> "_models.LogAnalyticsQueryPackQuery": + ) -> _models.LogAnalyticsQueryPackQuery: """Adds or Updates a specific Query within a Log Analytics QueryPack. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -586,18 +643,25 @@ def put( :param query_payload: Properties that need to be specified to create a new query and add it to a Log Analytics QueryPack. :type query_payload: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuery + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LogAnalyticsQueryPackQuery, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackQuery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsQueryPackQuery] _json = self._serialize.body(query_payload, 'LogAnalyticsQueryPackQuery') @@ -606,14 +670,21 @@ def put( resource_group_name=resource_group_name, query_pack_name=query_pack_name, id=id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -628,7 +699,7 @@ def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}"} # type: ignore @distributed_trace @@ -637,9 +708,9 @@ def update( resource_group_name: str, query_pack_name: str, id: str, - query_payload: "_models.LogAnalyticsQueryPackQuery", + query_payload: _models.LogAnalyticsQueryPackQuery, **kwargs: Any - ) -> "_models.LogAnalyticsQueryPackQuery": + ) -> _models.LogAnalyticsQueryPackQuery: """Adds or Updates a specific Query within a Log Analytics QueryPack. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -651,18 +722,25 @@ def update( :param query_payload: Properties that need to be specified to create a new query and add it to a Log Analytics QueryPack. :type query_payload: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuery + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LogAnalyticsQueryPackQuery, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackQuery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsQueryPackQuery] _json = self._serialize.body(query_payload, 'LogAnalyticsQueryPackQuery') @@ -671,14 +749,21 @@ def update( resource_group_name=resource_group_name, query_pack_name=query_pack_name, id=id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -693,11 +778,11 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, query_pack_name: str, @@ -712,16 +797,24 @@ def delete( :type query_pack_name: str :param id: The id of a specific query defined in the Log Analytics QueryPack. :type id: str + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -729,12 +822,19 @@ def delete( resource_group_name=resource_group_name, query_pack_name=query_pack_name, id=id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -745,5 +845,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_query_packs_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_query_packs_operations.py index 0ce4c437dd4a..294092d9776e 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_query_packs_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_query_packs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -31,29 +31,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/queryPacks') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/queryPacks") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -63,30 +65,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -97,31 +101,33 @@ def build_delete_request( query_pack_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "queryPackName": _SERIALIZER.url("query_pack_name", query_pack_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -132,31 +138,33 @@ def build_get_request( query_pack_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "queryPackName": _SERIALIZER.url("query_pack_name", query_pack_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -166,39 +174,40 @@ def build_create_or_update_request( subscription_id: str, query_pack_name: str, *, - json: JSONType = None, + json: Optional[_models.LogAnalyticsQueryPack] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "queryPackName": _SERIALIZER.url("query_pack_name", query_pack_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -210,73 +219,75 @@ def build_update_tags_request( subscription_id: str, query_pack_name: str, *, - json: JSONType = None, + json: Optional[_models.TagsResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "queryPackName": _SERIALIZER.url("query_pack_name", query_pack_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class QueryPacksOperations(object): - """QueryPacksOperations 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. +class QueryPacksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.LogAnalyticsManagementClient`'s + :attr:`query_packs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.LogAnalyticsQueryPackListResult"]: + ) -> Iterable[_models.LogAnalyticsQueryPackListResult]: """Gets a list of all Log Analytics QueryPacks within a subscription. + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LogAnalyticsQueryPackListResult or the result of cls(response) @@ -284,29 +295,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsQueryPackListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -320,7 +342,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -334,18 +360,21 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/queryPacks'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/queryPacks"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.LogAnalyticsQueryPackListResult"]: + ) -> Iterable[_models.LogAnalyticsQueryPackListResult]: """Gets a list of Log Analytics QueryPacks within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LogAnalyticsQueryPackListResult or the result of cls(response) @@ -353,31 +382,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsQueryPackListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -391,7 +431,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,10 +449,10 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, query_pack_name: str, @@ -420,28 +464,43 @@ def delete( :type resource_group_name: str :param query_pack_name: The name of the Log Analytics QueryPack resource. :type query_pack_name: str + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, query_pack_name=query_pack_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -452,7 +511,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}"} # type: ignore @distributed_trace @@ -461,35 +520,50 @@ def get( resource_group_name: str, query_pack_name: str, **kwargs: Any - ) -> "_models.LogAnalyticsQueryPack": + ) -> _models.LogAnalyticsQueryPack: """Returns a Log Analytics QueryPack. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param query_pack_name: The name of the Log Analytics QueryPack resource. :type query_pack_name: str + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LogAnalyticsQueryPack, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPack :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPack"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsQueryPack] request = build_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, query_pack_name=query_pack_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -504,7 +578,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}"} # type: ignore @distributed_trace @@ -512,9 +586,9 @@ def create_or_update( self, resource_group_name: str, query_pack_name: str, - log_analytics_query_pack_payload: "_models.LogAnalyticsQueryPack", + log_analytics_query_pack_payload: _models.LogAnalyticsQueryPack, **kwargs: Any - ) -> "_models.LogAnalyticsQueryPack": + ) -> _models.LogAnalyticsQueryPack: """Creates (or updates) a Log Analytics QueryPack. Note: You cannot specify a different value for InstrumentationKey nor AppId in the Put operation. @@ -525,18 +599,25 @@ def create_or_update( :param log_analytics_query_pack_payload: Properties that need to be specified to create or update a Log Analytics QueryPack. :type log_analytics_query_pack_payload: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPack + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LogAnalyticsQueryPack, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPack :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPack"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsQueryPack] _json = self._serialize.body(log_analytics_query_pack_payload, 'LogAnalyticsQueryPack') @@ -544,14 +625,21 @@ def create_or_update( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, query_pack_name=query_pack_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -566,7 +654,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}"} # type: ignore @distributed_trace @@ -574,9 +662,9 @@ def update_tags( self, resource_group_name: str, query_pack_name: str, - query_pack_tags: "_models.TagsResource", + query_pack_tags: _models.TagsResource, **kwargs: Any - ) -> "_models.LogAnalyticsQueryPack": + ) -> _models.LogAnalyticsQueryPack: """Updates an existing QueryPack's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -585,18 +673,25 @@ def update_tags( :type query_pack_name: str :param query_pack_tags: Updated tag information to set into the QueryPack instance. :type query_pack_tags: ~azure.mgmt.loganalytics.models.TagsResource + :keyword api_version: Api Version. Default value is "2019-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LogAnalyticsQueryPack, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPack :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPack"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsQueryPack] _json = self._serialize.body(query_pack_tags, 'TagsResource') @@ -604,14 +699,21 @@ def update_tags( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, query_pack_name=query_pack_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update_tags.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -626,5 +728,5 @@ def update_tags( return deserialized - update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}'} # type: ignore + update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_saved_searches_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_saved_searches_operations.py index 9fd0136a9f4c..d0f9cb7cb4c1 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_saved_searches_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_saved_searches_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,9 +33,11 @@ def build_delete_request( saved_search_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches/{savedSearchId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches/{savedSearchId}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -43,16 +45,15 @@ def build_delete_request( "savedSearchId": _SERIALIZER.url("saved_search_id", saved_search_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -63,16 +64,19 @@ def build_create_or_update_request( workspace_name: str, saved_search_id: str, *, - json: JSONType = None, + json: Optional[_models.SavedSearch] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches/{savedSearchId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches/{savedSearchId}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -80,23 +84,21 @@ def build_create_or_update_request( "savedSearchId": _SERIALIZER.url("saved_search_id", saved_search_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -110,10 +112,14 @@ def build_get_request( saved_search_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches/{savedSearchId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches/{savedSearchId}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -121,21 +127,19 @@ def build_get_request( "savedSearchId": _SERIALIZER.url("saved_search_id", saved_search_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -146,58 +150,58 @@ def build_list_by_workspace_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SavedSearchesOperations(object): - """SavedSearchesOperations 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. +class SavedSearchesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.LogAnalyticsManagementClient`'s + :attr:`saved_searches` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, @@ -212,16 +216,24 @@ def delete( :type workspace_name: str :param saved_search_id: The id of the saved search. :type saved_search_id: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -229,12 +241,19 @@ def delete( resource_group_name=resource_group_name, workspace_name=workspace_name, saved_search_id=saved_search_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -244,7 +263,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches/{savedSearchId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches/{savedSearchId}"} # type: ignore @distributed_trace @@ -253,9 +272,9 @@ def create_or_update( resource_group_name: str, workspace_name: str, saved_search_id: str, - parameters: "_models.SavedSearch", + parameters: _models.SavedSearch, **kwargs: Any - ) -> "_models.SavedSearch": + ) -> _models.SavedSearch: """Creates or updates a saved search for a given workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -266,18 +285,25 @@ def create_or_update( :type saved_search_id: str :param parameters: The parameters required to save a search. :type parameters: ~azure.mgmt.loganalytics.models.SavedSearch + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SavedSearch, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.SavedSearch :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SavedSearch"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SavedSearch] _json = self._serialize.body(parameters, 'SavedSearch') @@ -286,14 +312,21 @@ def create_or_update( resource_group_name=resource_group_name, workspace_name=workspace_name, saved_search_id=saved_search_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -307,7 +340,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches/{savedSearchId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches/{savedSearchId}"} # type: ignore @distributed_trace @@ -317,7 +350,7 @@ def get( workspace_name: str, saved_search_id: str, **kwargs: Any - ) -> "_models.SavedSearch": + ) -> _models.SavedSearch: """Gets the specified saved search for a given workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -326,16 +359,24 @@ def get( :type workspace_name: str :param saved_search_id: The id of the saved search. :type saved_search_id: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SavedSearch, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.SavedSearch :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SavedSearch"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SavedSearch] request = build_get_request( @@ -343,12 +384,19 @@ def get( resource_group_name=resource_group_name, workspace_name=workspace_name, saved_search_id=saved_search_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -362,7 +410,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches/{savedSearchId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches/{savedSearchId}"} # type: ignore @distributed_trace @@ -371,35 +419,50 @@ def list_by_workspace( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> "_models.SavedSearchesListResult": + ) -> _models.SavedSearchesListResult: """Gets the saved searches for a given Log Analytics Workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SavedSearchesListResult, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.SavedSearchesListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SavedSearchesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SavedSearchesListResult] request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_workspace.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -413,5 +476,5 @@ def list_by_workspace( return deserialized - list_by_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches'} # type: ignore + list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_schema_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_schema_operations.py index b1375421918c..e0b8d929d6bc 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_schema_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_schema_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,55 +32,55 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/schema') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/schema") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SchemaOperations(object): - """SchemaOperations 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. +class SchemaOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.LogAnalyticsManagementClient`'s + :attr:`schema` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -87,35 +88,50 @@ def get( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> "_models.SearchGetSchemaResponse": + ) -> _models.SearchGetSchemaResponse: """Gets the schema for a given workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SearchGetSchemaResponse, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.SearchGetSchemaResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SearchGetSchemaResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SearchGetSchemaResponse] request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -129,5 +145,5 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/schema'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/schema"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_shared_keys_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_shared_keys_operations.py index 33ae467863ff..8544584a8cc8 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_shared_keys_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_shared_keys_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,31 +32,33 @@ def build_get_shared_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/sharedKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/sharedKeys") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,55 +69,55 @@ def build_regenerate_request( workspace_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/regenerateSharedKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/regenerateSharedKey") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SharedKeysOperations(object): - """SharedKeysOperations 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. +class SharedKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.LogAnalyticsManagementClient`'s + :attr:`shared_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get_shared_keys( @@ -122,35 +125,50 @@ def get_shared_keys( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> "_models.SharedKeys": + ) -> _models.SharedKeys: """Gets the shared keys for a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SharedKeys, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.SharedKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedKeys"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedKeys] request = build_get_shared_keys_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_shared_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -164,7 +182,7 @@ def get_shared_keys( return deserialized - get_shared_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/sharedKeys'} # type: ignore + get_shared_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/sharedKeys"} # type: ignore @distributed_trace @@ -173,7 +191,7 @@ def regenerate( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> "_models.SharedKeys": + ) -> _models.SharedKeys: """Regenerates the shared keys for a Log Analytics Workspace. These keys are used to connect Microsoft Operational Insights agents to the workspace. @@ -181,28 +199,43 @@ def regenerate( :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SharedKeys, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.SharedKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedKeys"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedKeys] request = build_regenerate_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + api_version=api_version, template_url=self.regenerate.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -216,5 +249,5 @@ def regenerate( return deserialized - regenerate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/regenerateSharedKey'} # type: ignore + regenerate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/regenerateSharedKey"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_storage_insight_configs_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_storage_insight_configs_operations.py index 4d1e44c2dfb5..04da598bfefb 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_storage_insight_configs_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_storage_insight_configs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,16 +33,19 @@ def build_create_or_update_request( storage_insight_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageInsight] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs/{storageInsightName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs/{storageInsightName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), @@ -50,23 +53,21 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,10 +81,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs/{storageInsightName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs/{storageInsightName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), @@ -91,21 +96,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -117,9 +120,11 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs/{storageInsightName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs/{storageInsightName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), @@ -127,16 +132,15 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -147,55 +151,55 @@ def build_list_by_workspace_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class StorageInsightConfigsOperations(object): - """StorageInsightConfigsOperations 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. +class StorageInsightConfigsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.LogAnalyticsManagementClient`'s + :attr:`storage_insight_configs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create_or_update( @@ -203,9 +207,9 @@ def create_or_update( resource_group_name: str, workspace_name: str, storage_insight_name: str, - parameters: "_models.StorageInsight", + parameters: _models.StorageInsight, **kwargs: Any - ) -> "_models.StorageInsight": + ) -> _models.StorageInsight: """Create or update a storage insight. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -216,18 +220,25 @@ def create_or_update( :type storage_insight_name: str :param parameters: The parameters required to create or update a storage insight. :type parameters: ~azure.mgmt.loganalytics.models.StorageInsight + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageInsight, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.StorageInsight :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageInsight"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageInsight] _json = self._serialize.body(parameters, 'StorageInsight') @@ -236,14 +247,21 @@ def create_or_update( workspace_name=workspace_name, storage_insight_name=storage_insight_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -261,7 +279,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs/{storageInsightName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs/{storageInsightName}"} # type: ignore @distributed_trace @@ -271,7 +289,7 @@ def get( workspace_name: str, storage_insight_name: str, **kwargs: Any - ) -> "_models.StorageInsight": + ) -> _models.StorageInsight: """Gets a storage insight instance. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -280,16 +298,24 @@ def get( :type workspace_name: str :param storage_insight_name: Name of the storageInsightsConfigs resource. :type storage_insight_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageInsight, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.StorageInsight :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageInsight"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageInsight] request = build_get_request( @@ -297,12 +323,19 @@ def get( workspace_name=workspace_name, storage_insight_name=storage_insight_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -316,11 +349,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs/{storageInsightName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs/{storageInsightName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, @@ -335,16 +368,24 @@ def delete( :type workspace_name: str :param storage_insight_name: Name of the storageInsightsConfigs resource. :type storage_insight_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -352,12 +393,19 @@ def delete( workspace_name=workspace_name, storage_insight_name=storage_insight_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -367,7 +415,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs/{storageInsightName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs/{storageInsightName}"} # type: ignore @distributed_trace @@ -376,24 +424,32 @@ def list_by_workspace( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> Iterable["_models.StorageInsightListResult"]: + ) -> Iterable[_models.StorageInsightListResult]: """Lists the storage insight instances within a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageInsightListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.loganalytics.models.StorageInsightListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageInsightListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageInsightListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -401,10 +457,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_workspace.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -412,10 +471,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -429,7 +491,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -442,4 +508,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs'} # type: ignore + list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_tables_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_tables_operations.py index 92f630390a58..a700e65623b6 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_tables_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_tables_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -35,31 +35,33 @@ def build_list_by_workspace_request( workspace_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-12-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -70,16 +72,19 @@ def build_create_or_update_request_initial( workspace_name: str, table_name: str, *, - json: JSONType = None, + json: Optional[_models.Table] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-12-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -87,23 +92,21 @@ def build_create_or_update_request_initial( "tableName": _SERIALIZER.url("table_name", table_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -116,16 +119,19 @@ def build_update_request_initial( workspace_name: str, table_name: str, *, - json: JSONType = None, + json: Optional[_models.Table] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-12-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -133,23 +139,21 @@ def build_update_request_initial( "tableName": _SERIALIZER.url("table_name", table_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -163,10 +167,14 @@ def build_get_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-12-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -174,21 +182,19 @@ def build_get_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -200,10 +206,14 @@ def build_delete_request_initial( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-12-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -211,21 +221,19 @@ def build_delete_request_initial( "tableName": _SERIALIZER.url("table_name", table_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -237,10 +245,14 @@ def build_migrate_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-12-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}/migrate') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}/migrate") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -248,45 +260,41 @@ def build_migrate_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TablesOperations(object): - """TablesOperations 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. +class TablesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.LogAnalyticsManagementClient`'s + :attr:`tables` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_workspace( @@ -294,23 +302,31 @@ def list_by_workspace( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> Iterable["_models.TablesListResult"]: + ) -> Iterable[_models.TablesListResult]: """Gets all the tables for the specified Log Analytics workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TablesListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.loganalytics.models.TablesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TablesListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TablesListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -318,10 +334,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + api_version=api_version, template_url=self.list_by_workspace.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -329,10 +348,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -346,7 +368,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -360,23 +386,27 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_workspace.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables'} # type: ignore + list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, table_name: str, - parameters: "_models.Table", + parameters: _models.Table, **kwargs: Any - ) -> Optional["_models.Table"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Table"]] + ) -> Optional[_models.Table]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Table]] _json = self._serialize.body(parameters, 'Table') @@ -385,14 +415,21 @@ def _create_or_update_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, table_name=table_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -408,7 +445,7 @@ def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}"} # type: ignore @distributed_trace @@ -417,9 +454,9 @@ def begin_create_or_update( resource_group_name: str, workspace_name: str, table_name: str, - parameters: "_models.Table", + parameters: _models.Table, **kwargs: Any - ) -> LROPoller["_models.Table"]: + ) -> LROPoller[_models.Table]: """Update or Create a Log Analytics workspace table. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -430,6 +467,9 @@ def begin_create_or_update( :type table_name: str :param parameters: The parameters required to update table properties. :type parameters: ~azure.mgmt.loganalytics.models.Table + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: 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 @@ -442,36 +482,48 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.loganalytics.models.Table] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] 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( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, table_name=table_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('Table', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -480,26 +532,29 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}"} # type: ignore def _update_initial( self, resource_group_name: str, workspace_name: str, table_name: str, - parameters: "_models.Table", + parameters: _models.Table, **kwargs: Any - ) -> Optional["_models.Table"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Table"]] + ) -> Optional[_models.Table]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Table]] _json = self._serialize.body(parameters, 'Table') @@ -508,14 +563,21 @@ def _update_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, table_name=table_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -531,7 +593,7 @@ def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}"} # type: ignore @distributed_trace @@ -540,9 +602,9 @@ def begin_update( resource_group_name: str, workspace_name: str, table_name: str, - parameters: "_models.Table", + parameters: _models.Table, **kwargs: Any - ) -> LROPoller["_models.Table"]: + ) -> LROPoller[_models.Table]: """Update a Log Analytics workspace table. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -553,6 +615,9 @@ def begin_update( :type table_name: str :param parameters: The parameters required to update table properties. :type parameters: ~azure.mgmt.loganalytics.models.Table + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: 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 @@ -565,36 +630,48 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.loganalytics.models.Table] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] 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._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, table_name=table_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('Table', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -603,10 +680,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}"} # type: ignore @distributed_trace def get( @@ -615,7 +691,7 @@ def get( workspace_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Gets a Log Analytics workspace table. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -624,16 +700,24 @@ def get( :type workspace_name: str :param table_name: The name of the table. :type table_name: str + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Table, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_get_request( @@ -641,12 +725,19 @@ def get( resource_group_name=resource_group_name, workspace_name=workspace_name, table_name=table_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -661,21 +752,26 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}"} # type: ignore - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, table_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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -683,12 +779,19 @@ def _delete_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, table_name=table_name, + api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -698,11 +801,11 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}"} # type: ignore @distributed_trace - def begin_delete( + def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, @@ -717,6 +820,9 @@ def begin_delete( :type workspace_name: str :param table_name: The name of the table. :type table_name: str + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: 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 @@ -729,19 +835,26 @@ def begin_delete( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] 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( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, table_name=table_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -751,8 +864,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -761,13 +880,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}"} # type: ignore @distributed_trace - def migrate( + def migrate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, @@ -783,16 +901,24 @@ def migrate( :type workspace_name: str :param table_name: The name of the table. :type table_name: str + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_migrate_request( @@ -800,12 +926,19 @@ def migrate( resource_group_name=resource_group_name, workspace_name=workspace_name, table_name=table_name, + api_version=api_version, template_url=self.migrate.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -816,5 +949,5 @@ def migrate( if cls: return cls(pipeline_response, None, {}) - migrate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}/migrate'} # type: ignore + migrate.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}/migrate"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_usages_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_usages_operations.py index 7e769ff13ef3..e8e89763fad5 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_usages_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -32,55 +33,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/usages") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class UsagesOperations(object): - """UsagesOperations 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. +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.LogAnalyticsManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -88,24 +89,32 @@ def list( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> Iterable["_models.WorkspaceListUsagesResult"]: + ) -> Iterable[_models.WorkspaceListUsagesResult]: """Gets a list of usage metrics for a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkspaceListUsagesResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.loganalytics.models.WorkspaceListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceListUsagesResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspaceListUsagesResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -113,10 +122,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -124,10 +136,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -141,7 +156,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -154,4 +173,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/usages'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/usages"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_workspace_purge_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_workspace_purge_operations.py index c2db08c34b3a..67f4b12bb7d1 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_workspace_purge_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_workspace_purge_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -31,39 +31,40 @@ def build_purge_request( subscription_id: str, workspace_name: str, *, - json: JSONType = None, + json: Optional[_models.WorkspacePurgeBody] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/purge') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/purge") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -77,10 +78,14 @@ def build_get_purge_status_request( purge_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/operations/{purgeId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/operations/{purgeId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), @@ -88,54 +93,50 @@ def build_get_purge_status_request( "purgeId": _SERIALIZER.url("purge_id", purge_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class WorkspacePurgeOperations(object): - """WorkspacePurgeOperations 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. +class WorkspacePurgeOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.LogAnalyticsManagementClient`'s + :attr:`workspace_purge` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def purge( self, resource_group_name: str, workspace_name: str, - body: "_models.WorkspacePurgeBody", + body: _models.WorkspacePurgeBody, **kwargs: Any - ) -> "_models.WorkspacePurgeResponse": + ) -> _models.WorkspacePurgeResponse: """Purges data in an Log Analytics workspace by a set of user-defined filters. In order to manage system resources, purge requests are throttled at 50 requests per hour. You @@ -143,6 +144,9 @@ def purge( includes all user identities that require purging. Use the in operator to specify multiple identities. You should run the query prior to using for a purge request to verify that the results are expected. + Log Analytics only supports purge operations required for compliance with GDPR. The Log + Analytics product team reserves the right to reject requests for purge operations that are not + for the purpose of GDPR compliance. In the event of a dispute, please create a support ticket. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str @@ -151,18 +155,25 @@ def purge( :param body: Describes the body of a request to purge data in a single table of an Log Analytics Workspace. :type body: ~azure.mgmt.loganalytics.models.WorkspacePurgeBody + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkspacePurgeResponse, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.WorkspacePurgeResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspacePurgeResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspacePurgeResponse] _json = self._serialize.body(body, 'WorkspacePurgeBody') @@ -170,14 +181,21 @@ def purge( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, workspace_name=workspace_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.purge.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [202]: @@ -194,7 +212,7 @@ def purge( return deserialized - purge.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/purge'} # type: ignore + purge.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/purge"} # type: ignore @distributed_trace @@ -204,7 +222,7 @@ def get_purge_status( workspace_name: str, purge_id: str, **kwargs: Any - ) -> "_models.WorkspacePurgeStatusResponse": + ) -> _models.WorkspacePurgeStatusResponse: """Gets status of an ongoing purge operation. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -214,16 +232,24 @@ def get_purge_status( :param purge_id: In a purge status request, this is the Id of the operation the status of which is returned. :type purge_id: str + :keyword api_version: Api Version. Default value is "2020-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkspacePurgeStatusResponse, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.WorkspacePurgeStatusResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspacePurgeStatusResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspacePurgeStatusResponse] request = build_get_purge_status_request( @@ -231,12 +257,19 @@ def get_purge_status( subscription_id=self._config.subscription_id, workspace_name=workspace_name, purge_id=purge_id, + api_version=api_version, template_url=self.get_purge_status.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -250,5 +283,5 @@ def get_purge_status( return deserialized - get_purge_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/operations/{purgeId}'} # type: ignore + get_purge_status.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/operations/{purgeId}"} # type: ignore diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_workspaces_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_workspaces_operations.py index ecd41a4a6871..bf10e809fd86 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_workspaces_operations.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_workspaces_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,29 +33,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-12-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/workspaces') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/workspaces") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -65,30 +67,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-12-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -98,39 +102,40 @@ def build_create_or_update_request_initial( workspace_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.Workspace] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-12-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -145,33 +150,35 @@ def build_delete_request_initial( force: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-12-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if force is not None: - query_parameters['force'] = _SERIALIZER.query("force", force, 'bool') + _params['force'] = _SERIALIZER.query("force", force, 'bool') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -182,31 +189,33 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-12-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -216,101 +225,114 @@ def build_update_request( workspace_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.WorkspacePatch] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-12-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', max_length=63, min_length=4, pattern=r'^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class WorkspacesOperations(object): - """WorkspacesOperations 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. +class WorkspacesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.loganalytics.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. + Instead, you should access the following operations through + :class:`~azure.mgmt.loganalytics.LogAnalyticsManagementClient`'s + :attr:`workspaces` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.WorkspaceListResult"]: + ) -> Iterable[_models.WorkspaceListResult]: """Gets the workspaces in a subscription. + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkspaceListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.loganalytics.models.WorkspaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspaceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -324,7 +346,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -338,48 +364,62 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/workspaces'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/workspaces"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.WorkspaceListResult"]: + ) -> Iterable[_models.WorkspaceListResult]: """Gets workspaces in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkspaceListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.loganalytics.models.WorkspaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspaceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -393,7 +433,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -407,22 +451,26 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, - parameters: "_models.Workspace", + parameters: _models.Workspace, **kwargs: Any - ) -> Optional["_models.Workspace"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Workspace"]] + ) -> Optional[_models.Workspace]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Workspace]] _json = self._serialize.body(parameters, 'Workspace') @@ -430,14 +478,21 @@ def _create_or_update_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -456,7 +511,7 @@ def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}"} # type: ignore @distributed_trace @@ -464,9 +519,9 @@ def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - parameters: "_models.Workspace", + parameters: _models.Workspace, **kwargs: Any - ) -> LROPoller["_models.Workspace"]: + ) -> LROPoller[_models.Workspace]: """Create or update a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -475,6 +530,9 @@ def begin_create_or_update( :type workspace_name: str :param parameters: The parameters required to create or update a workspace. :type parameters: ~azure.mgmt.loganalytics.models.Workspace + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: 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 @@ -487,35 +545,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.loganalytics.models.Workspace] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Workspace"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Workspace] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] 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( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('Workspace', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -524,36 +594,47 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}"} # type: ignore - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, force: Optional[bool] = None, **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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, force=force, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -563,11 +644,11 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}"} # type: ignore @distributed_trace - def begin_delete( + def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, @@ -584,8 +665,11 @@ def begin_delete( :param workspace_name: The name of the workspace. :type workspace_name: str :param force: Deletes the workspace without the recovery option. A workspace that was deleted - with this flag cannot be recovered. + with this flag cannot be recovered. Default value is None. :type force: bool + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: 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 @@ -598,19 +682,26 @@ def begin_delete( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] 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( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, force=force, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -620,8 +711,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -630,10 +727,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}"} # type: ignore @distributed_trace def get( @@ -641,35 +737,50 @@ def get( resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> "_models.Workspace": + ) -> _models.Workspace: """Gets a workspace instance. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param workspace_name: The name of the workspace. :type workspace_name: str + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Workspace, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.Workspace :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Workspace"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Workspace] request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -684,7 +795,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}"} # type: ignore @distributed_trace @@ -692,9 +803,9 @@ def update( self, resource_group_name: str, workspace_name: str, - parameters: "_models.WorkspacePatch", + parameters: _models.WorkspacePatch, **kwargs: Any - ) -> "_models.Workspace": + ) -> _models.Workspace: """Updates a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -703,18 +814,25 @@ def update( :type workspace_name: str :param parameters: The parameters required to patch a workspace. :type parameters: ~azure.mgmt.loganalytics.models.WorkspacePatch + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Workspace, or the result of cls(response) :rtype: ~azure.mgmt.loganalytics.models.Workspace :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Workspace"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Workspace] _json = self._serialize.body(parameters, 'WorkspacePatch') @@ -722,14 +840,21 @@ def update( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -744,5 +869,5 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}"} # type: ignore