From a15ae156dfd966da9b8f4e482a24961ee79a6974 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 21 Oct 2024 06:05:18 +0000 Subject: [PATCH] CodeGen from PR 31112 in Azure/azure-rest-api-specs Merge cc24896b112eb55d2d95dda0cb1e03252588df15 into 637adebd6042eab6c721be8eda4ff3f5d4d0c2b8 --- sdk/elastic/azure-mgmt-elastic/README.md | 7 +- sdk/elastic/azure-mgmt-elastic/_meta.json | 10 +- .../azure/mgmt/elastic/_configuration.py | 14 +- .../azure/mgmt/elastic/_microsoft_elastic.py | 56 +- .../azure/mgmt/elastic/_serialization.py | 118 +-- .../azure/mgmt/elastic/_vendor.py | 30 - .../azure/mgmt/elastic/_version.py | 2 +- .../azure/mgmt/elastic/aio/_configuration.py | 14 +- .../mgmt/elastic/aio/_microsoft_elastic.py | 58 +- .../mgmt/elastic/aio/operations/__init__.py | 8 + .../_all_traffic_filters_operations.py | 38 +- .../_associate_traffic_filter_operations.py | 71 +- .../operations/_billing_info_operations.py | 114 +++ ..._connected_partner_resources_operations.py | 148 +++ ...eate_and_associate_ip_filter_operations.py | 71 +- ...eate_and_associate_pl_filter_operations.py | 71 +- .../operations/_deployment_info_operations.py | 38 +- ...ch_and_delete_traffic_filter_operations.py | 34 +- .../_detach_traffic_filter_operations.py | 71 +- .../_elastic_versions_operations.py | 37 +- .../operations/_external_user_operations.py | 64 +- ...t_associated_traffic_filters_operations.py | 38 +- .../aio/operations/_monitor_operations.py | 115 +-- .../_monitored_resources_operations.py | 43 +- .../_monitored_subscriptions_operations.py | 773 ++++++++++++++ .../aio/operations/_monitors_operations.py | 474 +++++---- .../aio/operations/_open_ai_operations.py | 497 +++++++++ .../elastic/aio/operations/_operations.py | 37 +- .../operations/_organizations_operations.py | 323 +++++- .../aio/operations/_tag_rules_operations.py | 179 ++-- .../operations/_traffic_filters_operations.py | 34 +- .../_upgradable_versions_operations.py | 38 +- .../operations/_vm_collection_operations.py | 62 +- .../aio/operations/_vm_host_operations.py | 43 +- .../operations/_vm_ingestion_operations.py | 38 +- .../azure/mgmt/elastic/models/__init__.py | 46 + .../models/_microsoft_elastic_enums.py | 19 + .../azure/mgmt/elastic/models/_models_py3.py | 938 ++++++++++++++++- .../azure/mgmt/elastic/operations/__init__.py | 8 + .../_all_traffic_filters_operations.py | 48 +- .../_associate_traffic_filter_operations.py | 81 +- .../operations/_billing_info_operations.py | 148 +++ ..._connected_partner_resources_operations.py | 182 ++++ ...eate_and_associate_ip_filter_operations.py | 81 +- ...eate_and_associate_pl_filter_operations.py | 81 +- .../operations/_deployment_info_operations.py | 48 +- ...ch_and_delete_traffic_filter_operations.py | 44 +- .../_detach_traffic_filter_operations.py | 81 +- .../_elastic_versions_operations.py | 41 +- .../operations/_external_user_operations.py | 74 +- ...t_associated_traffic_filters_operations.py | 48 +- .../elastic/operations/_monitor_operations.py | 125 +-- .../_monitored_resources_operations.py | 53 +- .../_monitored_subscriptions_operations.py | 942 ++++++++++++++++++ .../operations/_monitors_operations.py | 526 +++++----- .../elastic/operations/_open_ai_operations.py | 662 ++++++++++++ .../mgmt/elastic/operations/_operations.py | 39 +- .../operations/_organizations_operations.py | 386 ++++++- .../operations/_tag_rules_operations.py | 225 ++--- .../operations/_traffic_filters_operations.py | 44 +- .../_upgradable_versions_operations.py | 48 +- .../operations/_vm_collection_operations.py | 72 +- .../elastic/operations/_vm_host_operations.py | 53 +- .../operations/_vm_ingestion_operations.py | 48 +- .../all_traffic_filters_list.py | 3 +- .../associate_traffic_filter_update.py | 6 +- .../associated_filters_for_deployment_list.py | 3 +- .../generated_samples/billing_info_get.py | 42 + .../connected_partner_resources_list.py | 43 + .../generated_samples/deployment_info_list.py | 3 +- ...detach_and_delete_traffic_filter_delete.py | 6 +- .../detach_traffic_filters_update.py | 6 +- .../elastic_versions_list.py | 3 +- .../generated_samples/external_user_info.py | 3 +- .../ip_traffic_filter_create.py | 6 +- .../generated_samples/monitor_upgrade.py | 6 +- .../monitored_resources_list.py | 3 +- ...monitored_subscriptions_createor_update.py | 43 + .../monitored_subscriptions_delete.py | 42 + .../monitored_subscriptions_get.py | 43 + .../monitored_subscriptions_list.py | 43 + .../monitored_subscriptions_update.py | 43 + .../generated_samples/monitors_create.py | 3 +- .../generated_samples/monitors_delete.py | 6 +- .../generated_samples/monitors_get.py | 3 +- .../generated_samples/monitors_list.py | 3 +- .../monitors_list_by_resource_group.py | 3 +- .../generated_samples/monitors_update.py | 7 +- .../open_ai_create_or_update.py | 43 + .../generated_samples/open_ai_delete.py | 42 + .../generated_samples/open_ai_get.py | 43 + .../generated_samples/open_ai_get_status.py | 43 + .../generated_samples/open_ai_list.py | 43 + .../generated_samples/operations_list.py | 3 +- .../organizations_get_api_key.py | 3 +- ...t_elastic_to_azure_subscription_mapping.py | 39 + .../organizations_resubscribe.py | 42 + .../private_link_traffic_filters_create.py | 6 +- .../tag_rules_create_or_update.py | 3 +- .../generated_samples/tag_rules_delete.py | 6 +- .../generated_samples/tag_rules_get.py | 3 +- .../generated_samples/tag_rules_list.py | 3 +- .../traffic_filters_delete.py | 6 +- .../upgradable_versions_details.py | 3 +- .../generated_samples/vm_collection_update.py | 6 +- .../generated_samples/vm_host_list.py | 3 +- .../generated_samples/vm_ingestion_details.py | 3 +- .../generated_tests/conftest.py | 35 + ..._elastic_all_traffic_filters_operations.py | 31 + ...ic_all_traffic_filters_operations_async.py | 32 + ...tic_associate_traffic_filter_operations.py | 31 + ...sociate_traffic_filter_operations_async.py | 34 + ...crosoft_elastic_billing_info_operations.py | 31 + ...t_elastic_billing_info_operations_async.py | 32 + ..._connected_partner_resources_operations.py | 31 + ...cted_partner_resources_operations_async.py | 32 + ...eate_and_associate_ip_filter_operations.py | 31 + ...nd_associate_ip_filter_operations_async.py | 34 + ...eate_and_associate_pl_filter_operations.py | 31 + ...nd_associate_pl_filter_operations_async.py | 34 + ...soft_elastic_deployment_info_operations.py | 31 + ...lastic_deployment_info_operations_async.py | 32 + ...ch_and_delete_traffic_filter_operations.py | 31 + ..._delete_traffic_filter_operations_async.py | 32 + ...lastic_detach_traffic_filter_operations.py | 31 + ..._detach_traffic_filter_operations_async.py | 34 + ...oft_elastic_elastic_versions_operations.py | 30 + ...astic_elastic_versions_operations_async.py | 31 + ...rosoft_elastic_external_user_operations.py | 31 + ..._elastic_external_user_operations_async.py | 32 + ...t_associated_traffic_filters_operations.py | 31 + ...ciated_traffic_filters_operations_async.py | 32 + ...st_microsoft_elastic_monitor_operations.py | 31 + ...rosoft_elastic_monitor_operations_async.py | 34 + ..._elastic_monitored_resources_operations.py | 31 + ...ic_monitored_resources_operations_async.py | 32 + ...stic_monitored_subscriptions_operations.py | 83 ++ ...onitored_subscriptions_operations_async.py | 90 ++ ...t_microsoft_elastic_monitors_operations.py | 88 ++ ...osoft_elastic_monitors_operations_async.py | 95 ++ ...st_microsoft_elastic_open_ai_operations.py | 83 ++ ...rosoft_elastic_open_ai_operations_async.py | 84 ++ .../test_microsoft_elastic_operations.py | 29 + ...test_microsoft_elastic_operations_async.py | 30 + ...rosoft_elastic_organizations_operations.py | 51 + ..._elastic_organizations_operations_async.py | 54 + ..._microsoft_elastic_tag_rules_operations.py | 70 ++ ...soft_elastic_tag_rules_operations_async.py | 73 ++ ...soft_elastic_traffic_filters_operations.py | 31 + ...lastic_traffic_filters_operations_async.py | 32 + ..._elastic_upgradable_versions_operations.py | 31 + ...ic_upgradable_versions_operations_async.py | 32 + ...rosoft_elastic_vm_collection_operations.py | 31 + ..._elastic_vm_collection_operations_async.py | 32 + ...st_microsoft_elastic_vm_host_operations.py | 31 + ...rosoft_elastic_vm_host_operations_async.py | 32 + ...crosoft_elastic_vm_ingestion_operations.py | 31 + ...t_elastic_vm_ingestion_operations_async.py | 32 + sdk/elastic/azure-mgmt-elastic/setup.py | 86 +- 159 files changed, 9694 insertions(+), 2136 deletions(-) delete mode 100644 sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/_vendor.py create mode 100644 sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_billing_info_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_connected_partner_resources_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_monitored_subscriptions_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_open_ai_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_billing_info_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_connected_partner_resources_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_monitored_subscriptions_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_open_ai_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_samples/billing_info_get.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_samples/connected_partner_resources_list.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_subscriptions_createor_update.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_subscriptions_delete.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_subscriptions_get.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_subscriptions_list.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_subscriptions_update.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_samples/open_ai_create_or_update.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_samples/open_ai_delete.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_samples/open_ai_get.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_samples/open_ai_get_status.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_samples/open_ai_list.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_samples/organizations_get_elastic_to_azure_subscription_mapping.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_samples/organizations_resubscribe.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/conftest.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_all_traffic_filters_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_all_traffic_filters_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_associate_traffic_filter_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_associate_traffic_filter_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_billing_info_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_billing_info_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_connected_partner_resources_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_connected_partner_resources_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_create_and_associate_ip_filter_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_create_and_associate_ip_filter_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_create_and_associate_pl_filter_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_create_and_associate_pl_filter_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_deployment_info_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_deployment_info_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_detach_and_delete_traffic_filter_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_detach_and_delete_traffic_filter_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_detach_traffic_filter_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_detach_traffic_filter_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_elastic_versions_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_elastic_versions_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_external_user_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_external_user_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_list_associated_traffic_filters_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_list_associated_traffic_filters_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitor_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitor_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitored_resources_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitored_resources_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitored_subscriptions_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitored_subscriptions_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitors_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitors_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_open_ai_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_open_ai_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_organizations_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_organizations_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_tag_rules_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_tag_rules_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_traffic_filters_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_traffic_filters_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_upgradable_versions_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_upgradable_versions_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_collection_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_collection_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_host_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_host_operations_async.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_ingestion_operations.py create mode 100644 sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_ingestion_operations_async.py diff --git a/sdk/elastic/azure-mgmt-elastic/README.md b/sdk/elastic/azure-mgmt-elastic/README.md index 96396e290d4f..ebb727a84a64 100644 --- a/sdk/elastic/azure-mgmt-elastic/README.md +++ b/sdk/elastic/azure-mgmt-elastic/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Elastic Management Client Library. -This package has been tested with Python 3.7+. +This package has been tested with Python 3.8+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.7+ is required to use this package. +- Python 3.8+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -59,6 +59,3 @@ Code samples for this package can be found at: If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project. - - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-elastic%2FREADME.png) diff --git a/sdk/elastic/azure-mgmt-elastic/_meta.json b/sdk/elastic/azure-mgmt-elastic/_meta.json index 99a262400bd8..d2088aba9f2d 100644 --- a/sdk/elastic/azure-mgmt-elastic/_meta.json +++ b/sdk/elastic/azure-mgmt-elastic/_meta.json @@ -1,11 +1,11 @@ { - "commit": "1f449b5a17448f05ce1cd914f8ed75a0b568d130", + "commit": "7ec172fb12d6683a568b81acc1e89fa3ac01e979", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.4.8", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.19.0", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/elastic/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.4.8 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/elastic/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/elastic/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/_configuration.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/_configuration.py index 8273c3f2bcde..9f4d67b769bb 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/_configuration.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class MicrosoftElasticConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class MicrosoftElasticConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for MicrosoftElastic. Note that all parameters used to create this instance are saved as instance @@ -27,17 +26,15 @@ class MicrosoftElasticConfiguration(Configuration): # pylint: disable=too-many- :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. - 00000000-0000-0000-0000-000000000000). Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-02-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-10-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MicrosoftElasticConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-02-01-preview") + api_version: str = kwargs.pop("api_version", "2024-10-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -49,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-elastic/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -57,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/_microsoft_elastic.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/_microsoft_elastic.py index e931c84eb210..3863ed33ce7f 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/_microsoft_elastic.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/_microsoft_elastic.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from ._configuration import MicrosoftElasticConfiguration @@ -18,6 +21,8 @@ from .operations import ( AllTrafficFiltersOperations, AssociateTrafficFilterOperations, + BillingInfoOperations, + ConnectedPartnerResourcesOperations, CreateAndAssociateIPFilterOperations, CreateAndAssociatePLFilterOperations, DeploymentInfoOperations, @@ -28,7 +33,9 @@ ListAssociatedTrafficFiltersOperations, MonitorOperations, MonitoredResourcesOperations, + MonitoredSubscriptionsOperations, MonitorsOperations, + OpenAIOperations, Operations, OrganizationsOperations, TagRulesOperations, @@ -53,12 +60,22 @@ class MicrosoftElastic: # pylint: disable=client-accepts-api-version-keyword,to :vartype monitors: azure.mgmt.elastic.operations.MonitorsOperations :ivar elastic_versions: ElasticVersionsOperations operations :vartype elastic_versions: azure.mgmt.elastic.operations.ElasticVersionsOperations + :ivar monitored_subscriptions: MonitoredSubscriptionsOperations operations + :vartype monitored_subscriptions: + azure.mgmt.elastic.operations.MonitoredSubscriptionsOperations :ivar monitored_resources: MonitoredResourcesOperations operations :vartype monitored_resources: azure.mgmt.elastic.operations.MonitoredResourcesOperations :ivar deployment_info: DeploymentInfoOperations operations :vartype deployment_info: azure.mgmt.elastic.operations.DeploymentInfoOperations :ivar external_user: ExternalUserOperations operations :vartype external_user: azure.mgmt.elastic.operations.ExternalUserOperations + :ivar billing_info: BillingInfoOperations operations + :vartype billing_info: azure.mgmt.elastic.operations.BillingInfoOperations + :ivar connected_partner_resources: ConnectedPartnerResourcesOperations operations + :vartype connected_partner_resources: + azure.mgmt.elastic.operations.ConnectedPartnerResourcesOperations + :ivar open_ai: OpenAIOperations operations + :vartype open_ai: azure.mgmt.elastic.operations.OpenAIOperations :ivar tag_rules: TagRulesOperations operations :vartype tag_rules: azure.mgmt.elastic.operations.TagRulesOperations :ivar vm_host: VMHostOperations operations @@ -96,12 +113,11 @@ class MicrosoftElastic: # pylint: disable=client-accepts-api-version-keyword,to :vartype organizations: azure.mgmt.elastic.operations.OrganizationsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. - 00000000-0000-0000-0000-000000000000). Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-02-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-10-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -116,7 +132,25 @@ def __init__( **kwargs: Any ) -> None: self._config = MicrosoftElasticConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -127,11 +161,19 @@ def __init__( self.elastic_versions = ElasticVersionsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.monitored_subscriptions = MonitoredSubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.monitored_resources = MonitoredResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) self.deployment_info = DeploymentInfoOperations(self._client, self._config, self._serialize, self._deserialize) self.external_user = ExternalUserOperations(self._client, self._config, self._serialize, self._deserialize) + self.billing_info = BillingInfoOperations(self._client, self._config, self._serialize, self._deserialize) + self.connected_partner_resources = ConnectedPartnerResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.open_ai = OpenAIOperations(self._client, self._config, self._serialize, self._deserialize) self.tag_rules = TagRulesOperations(self._client, self._config, self._serialize, self._deserialize) self.vm_host = VMHostOperations(self._client, self._config, self._serialize, self._deserialize) self.vm_ingestion = VMIngestionOperations(self._client, self._config, self._serialize, self._deserialize) @@ -164,7 +206,7 @@ def __init__( self.traffic_filters = TrafficFiltersOperations(self._client, self._config, self._serialize, self._deserialize) self.organizations = OrganizationsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -184,12 +226,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "MicrosoftElastic": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/_serialization.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/_serialization.py index 842ae727fbbc..8139854b97bb 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/_serialization.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/_serialization.py @@ -63,8 +63,8 @@ import isodate # type: ignore -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback -from azure.core.serialization import NULL as AzureCoreNull +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") @@ -124,7 +124,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -143,7 +143,9 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -170,13 +172,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -295,7 +290,7 @@ class Model(object): _validation: Dict[str, Dict[str, Any]] = {} def __init__(self, **kwargs: Any) -> None: - self.additional_properties: Dict[str, Any] = {} + self.additional_properties: Optional[Dict[str, Any]] = {} for k in kwargs: if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -340,7 +335,7 @@ def _create_xml_node(cls): return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to azure from this model. + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -351,7 +346,7 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore def as_dict( self, @@ -390,7 +385,7 @@ def my_key_transformer(key, attr_desc, value): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore @classmethod def _infer_class_models(cls): @@ -415,7 +410,7 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( @@ -445,7 +440,7 @@ def from_dict( if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -545,7 +540,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -561,7 +556,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -649,7 +644,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = unicode_str(new_attr) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore @@ -662,12 +657,13 @@ def _serialize(self, target_obj, data_type=None, **kwargs): _serialized.update(_new_attr) # type: ignore _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err else: return serialized @@ -709,7 +705,7 @@ def body(self, data, data_type, **kwargs): ] data = deserializer._deserialize(data_type, data) except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) @@ -729,6 +725,7 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") except SerializationError: @@ -741,7 +738,9 @@ def query(self, name, data, data_type, **kwargs): :param data: The data to be serialized. :param str data_type: The type to be serialized from. - :rtype: str + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -749,10 +748,8 @@ def query(self, name, data, data_type, **kwargs): # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get("skip_quote", False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -803,7 +800,7 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: - if data is AzureCoreNull: + if data is CoreNull: return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -823,7 +820,7 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback(SerializationError, msg.format(data, data_type), err) + raise SerializationError(msg.format(data, data_type)) from err else: return self._serialize(data, **kwargs) @@ -891,6 +888,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. :rtype: list, str """ if isinstance(data, str): @@ -903,9 +902,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -950,7 +954,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: @@ -983,7 +989,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) if obj_type is _long_type: return self.serialize_long(attr) - if obj_type is unicode_str: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -1160,10 +1166,10 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod def serialize_unix(attr, **kwargs): @@ -1199,7 +1205,6 @@ def rest_key_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1220,7 +1225,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1361,7 +1365,7 @@ class Deserializer(object): valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1381,7 +1385,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1434,12 +1438,12 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: attributes = response._attribute_map # type: ignore @@ -1471,7 +1475,7 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1505,14 +1509,14 @@ def _classify_target(self, target, data): if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1568,7 +1572,7 @@ def _unpack_content(raw_data, content_type=None): if hasattr(raw_data, "_content_consumed"): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data @@ -1642,7 +1646,7 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return self._deserialize(obj_type, data) @@ -1690,7 +1694,7 @@ def deserialize_object(self, attr, **kwargs): if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1747,7 +1751,7 @@ def deserialize_basic(self, attr, data_type): if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + elif isinstance(attr, str): if attr.lower() in ["true", "1"]: return True elif attr.lower() in ["false", "0"]: @@ -1798,7 +1802,6 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] except IndexError: @@ -1852,10 +1855,10 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): @@ -1883,7 +1886,7 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return duration @@ -1900,7 +1903,7 @@ def deserialize_date(attr): if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): @@ -1935,7 +1938,7 @@ def deserialize_rfc(attr): date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1972,7 +1975,7 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1988,9 +1991,10 @@ def deserialize_unix(attr): if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/_vendor.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/_version.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/_version.py index 73aef742777f..e5754a47ce68 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/_version.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.1.0b3" +VERSION = "1.0.0b1" diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/_configuration.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/_configuration.py index d692acb9479c..20d035b73d4d 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/_configuration.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MicrosoftElasticConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class MicrosoftElasticConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for MicrosoftElastic. Note that all parameters used to create this instance are saved as instance @@ -27,17 +26,15 @@ class MicrosoftElasticConfiguration(Configuration): # pylint: disable=too-many- :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. - 00000000-0000-0000-0000-000000000000). Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-02-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-10-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MicrosoftElasticConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-02-01-preview") + api_version: str = kwargs.pop("api_version", "2024-10-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -49,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-elastic/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -57,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/_microsoft_elastic.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/_microsoft_elastic.py index 9af83af61936..283bc3052be8 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/_microsoft_elastic.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/_microsoft_elastic.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from .._serialization import Deserializer, Serializer @@ -18,6 +21,8 @@ from .operations import ( AllTrafficFiltersOperations, AssociateTrafficFilterOperations, + BillingInfoOperations, + ConnectedPartnerResourcesOperations, CreateAndAssociateIPFilterOperations, CreateAndAssociatePLFilterOperations, DeploymentInfoOperations, @@ -28,7 +33,9 @@ ListAssociatedTrafficFiltersOperations, MonitorOperations, MonitoredResourcesOperations, + MonitoredSubscriptionsOperations, MonitorsOperations, + OpenAIOperations, Operations, OrganizationsOperations, TagRulesOperations, @@ -53,12 +60,22 @@ class MicrosoftElastic: # pylint: disable=client-accepts-api-version-keyword,to :vartype monitors: azure.mgmt.elastic.aio.operations.MonitorsOperations :ivar elastic_versions: ElasticVersionsOperations operations :vartype elastic_versions: azure.mgmt.elastic.aio.operations.ElasticVersionsOperations + :ivar monitored_subscriptions: MonitoredSubscriptionsOperations operations + :vartype monitored_subscriptions: + azure.mgmt.elastic.aio.operations.MonitoredSubscriptionsOperations :ivar monitored_resources: MonitoredResourcesOperations operations :vartype monitored_resources: azure.mgmt.elastic.aio.operations.MonitoredResourcesOperations :ivar deployment_info: DeploymentInfoOperations operations :vartype deployment_info: azure.mgmt.elastic.aio.operations.DeploymentInfoOperations :ivar external_user: ExternalUserOperations operations :vartype external_user: azure.mgmt.elastic.aio.operations.ExternalUserOperations + :ivar billing_info: BillingInfoOperations operations + :vartype billing_info: azure.mgmt.elastic.aio.operations.BillingInfoOperations + :ivar connected_partner_resources: ConnectedPartnerResourcesOperations operations + :vartype connected_partner_resources: + azure.mgmt.elastic.aio.operations.ConnectedPartnerResourcesOperations + :ivar open_ai: OpenAIOperations operations + :vartype open_ai: azure.mgmt.elastic.aio.operations.OpenAIOperations :ivar tag_rules: TagRulesOperations operations :vartype tag_rules: azure.mgmt.elastic.aio.operations.TagRulesOperations :ivar vm_host: VMHostOperations operations @@ -96,12 +113,11 @@ class MicrosoftElastic: # pylint: disable=client-accepts-api-version-keyword,to :vartype organizations: azure.mgmt.elastic.aio.operations.OrganizationsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. - 00000000-0000-0000-0000-000000000000). Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-02-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-10-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -116,7 +132,25 @@ def __init__( **kwargs: Any ) -> None: self._config = MicrosoftElasticConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -127,11 +161,19 @@ def __init__( self.elastic_versions = ElasticVersionsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.monitored_subscriptions = MonitoredSubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.monitored_resources = MonitoredResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) self.deployment_info = DeploymentInfoOperations(self._client, self._config, self._serialize, self._deserialize) self.external_user = ExternalUserOperations(self._client, self._config, self._serialize, self._deserialize) + self.billing_info = BillingInfoOperations(self._client, self._config, self._serialize, self._deserialize) + self.connected_partner_resources = ConnectedPartnerResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.open_ai = OpenAIOperations(self._client, self._config, self._serialize, self._deserialize) self.tag_rules = TagRulesOperations(self._client, self._config, self._serialize, self._deserialize) self.vm_host = VMHostOperations(self._client, self._config, self._serialize, self._deserialize) self.vm_ingestion = VMIngestionOperations(self._client, self._config, self._serialize, self._deserialize) @@ -164,7 +206,9 @@ def __init__( self.traffic_filters = TrafficFiltersOperations(self._client, self._config, self._serialize, self._deserialize) self.organizations = OrganizationsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -184,12 +228,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "MicrosoftElastic": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/__init__.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/__init__.py index e04a06140193..1cdfeb9a7b42 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/__init__.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/__init__.py @@ -9,9 +9,13 @@ from ._operations import Operations from ._monitors_operations import MonitorsOperations from ._elastic_versions_operations import ElasticVersionsOperations +from ._monitored_subscriptions_operations import MonitoredSubscriptionsOperations from ._monitored_resources_operations import MonitoredResourcesOperations from ._deployment_info_operations import DeploymentInfoOperations from ._external_user_operations import ExternalUserOperations +from ._billing_info_operations import BillingInfoOperations +from ._connected_partner_resources_operations import ConnectedPartnerResourcesOperations +from ._open_ai_operations import OpenAIOperations from ._tag_rules_operations import TagRulesOperations from ._vm_host_operations import VMHostOperations from ._vm_ingestion_operations import VMIngestionOperations @@ -36,9 +40,13 @@ "Operations", "MonitorsOperations", "ElasticVersionsOperations", + "MonitoredSubscriptionsOperations", "MonitoredResourcesOperations", "DeploymentInfoOperations", "ExternalUserOperations", + "BillingInfoOperations", + "ConnectedPartnerResourcesOperations", + "OpenAIOperations", "TagRulesOperations", "VMHostOperations", "VMIngestionOperations", diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_all_traffic_filters_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_all_traffic_filters_operations.py index 1531baef4334..861ff93eff4e 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_all_traffic_filters_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_all_traffic_filters_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._all_traffic_filters_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,17 +61,16 @@ async def list( Get the list of all traffic filters for the account. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ElasticTrafficFilterResponse or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.ElasticTrafficFilterResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,21 +84,19 @@ async def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticTrafficFilterResponse] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, monitor_name=monitor_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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -108,13 +108,9 @@ async def list( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ElasticTrafficFilterResponse", pipeline_response) + deserialized = self._deserialize("ElasticTrafficFilterResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/listAllTrafficFilters" - } + return deserialized # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_associate_traffic_filter_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_associate_traffic_filter_operations.py index f40bfed1a937..7f5521f5ebc8 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_associate_traffic_filter_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_associate_traffic_filter_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterator, Callable, Dict, Optional, Type, TypeVar, Union, cast from azure.core.exceptions import ( ClientAuthenticationError, @@ -14,21 +15,25 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._associate_traffic_filter_operations import build_associate_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -52,10 +57,10 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = 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 _associate_initial( # pylint: disable=inconsistent-return-statements + async def _associate_initial( self, resource_group_name: str, monitor_name: str, ruleset_id: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -67,41 +72,44 @@ async def _associate_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_associate_request( + _request = build_associate_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, ruleset_id=ruleset_id, api_version=api_version, - template_url=self._associate_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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( _models.ResourceProviderDefaultErrorResponse, pipeline_response ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _associate_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/associateTrafficFilter" - } + return deserialized # type: ignore @distributed_trace_async async def begin_associate( @@ -111,21 +119,13 @@ async def begin_associate( Associate traffic filter for the given deployment. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param ruleset_id: Ruleset Id of the filter. Default value is None. :type ruleset_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -139,7 +139,7 @@ async def begin_associate( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._associate_initial( # type: ignore + raw_result = await self._associate_initial( resource_group_name=resource_group_name, monitor_name=monitor_name, ruleset_id=ruleset_id, @@ -149,11 +149,12 @@ async def begin_associate( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -164,14 +165,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_associate.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/associateTrafficFilter" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_billing_info_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_billing_info_operations.py new file mode 100644 index 000000000000..f3106e9bb129 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_billing_info_operations.py @@ -0,0 +1,114 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._billing_info_operations import build_get_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BillingInfoOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elastic.aio.MicrosoftElastic`'s + :attr:`billing_info` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> _models.BillingInfoResponse: + """Get marketplace and organization info mapped to the given monitor. + + Get marketplace and organization info mapped to the given monitor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :return: BillingInfoResponse or the result of cls(response) + :rtype: ~azure.mgmt.elastic.models.BillingInfoResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.BillingInfoResponse] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ResourceProviderDefaultErrorResponse, pipeline_response + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BillingInfoResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_connected_partner_resources_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_connected_partner_resources_operations.py new file mode 100644 index 000000000000..b9053d30bbb5 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_connected_partner_resources_operations.py @@ -0,0 +1,148 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._connected_partner_resources_operations import build_list_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ConnectedPartnerResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elastic.aio.MicrosoftElastic`'s + :attr:`connected_partner_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, monitor_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ConnectedPartnerResourcesListFormat"]: + """List of all active deployments that are associated with the marketplace subscription linked to + the given monitor. + + List of all active deployments that are associated with the marketplace subscription linked to + the given monitor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :return: An iterator like instance of either ConnectedPartnerResourcesListFormat or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elastic.models.ConnectedPartnerResourcesListFormat] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ConnectedPartnerResourcesListResponse] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ConnectedPartnerResourcesListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ResourceProviderDefaultErrorResponse, pipeline_response + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_create_and_associate_ip_filter_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_create_and_associate_ip_filter_operations.py index 681032d9ed38..a0c6b8261e62 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_create_and_associate_ip_filter_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_create_and_associate_ip_filter_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterator, Callable, Dict, Optional, Type, TypeVar, Union, cast from azure.core.exceptions import ( ClientAuthenticationError, @@ -14,21 +15,25 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._create_and_associate_ip_filter_operations import build_create_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -52,15 +57,15 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = 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_initial( # pylint: disable=inconsistent-return-statements + async def _create_initial( self, resource_group_name: str, monitor_name: str, ips: Optional[str] = None, name: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -72,42 +77,45 @@ async def _create_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, ips=ips, name=name, api_version=api_version, - template_url=self._create_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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( _models.ResourceProviderDefaultErrorResponse, pipeline_response ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/createAndAssociateIPFilter" - } + return deserialized # type: ignore @distributed_trace_async async def begin_create( @@ -122,8 +130,8 @@ async def begin_create( Create and Associate IP traffic filter for the given deployment. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str @@ -131,14 +139,6 @@ async def begin_create( :type ips: str :param name: Name of the traffic filter. Default value is None. :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -152,7 +152,7 @@ async def begin_create( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_initial( # type: ignore + raw_result = await self._create_initial( resource_group_name=resource_group_name, monitor_name=monitor_name, ips=ips, @@ -163,11 +163,12 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -178,14 +179,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/createAndAssociateIPFilter" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_create_and_associate_pl_filter_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_create_and_associate_pl_filter_operations.py index 46adcc10b04d..0484a59d57f6 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_create_and_associate_pl_filter_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_create_and_associate_pl_filter_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterator, Callable, Dict, Optional, Type, TypeVar, Union, cast from azure.core.exceptions import ( ClientAuthenticationError, @@ -14,21 +15,25 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._create_and_associate_pl_filter_operations import build_create_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = 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_initial( # pylint: disable=inconsistent-return-statements + async def _create_initial( self, resource_group_name: str, monitor_name: str, @@ -60,8 +65,8 @@ async def _create_initial( # pylint: disable=inconsistent-return-statements private_endpoint_guid: Optional[str] = None, private_endpoint_name: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -73,9 +78,9 @@ async def _create_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, @@ -83,33 +88,36 @@ async def _create_initial( # pylint: disable=inconsistent-return-statements private_endpoint_guid=private_endpoint_guid, private_endpoint_name=private_endpoint_name, api_version=api_version, - template_url=self._create_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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( _models.ResourceProviderDefaultErrorResponse, pipeline_response ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/createAndAssociatePLFilter" - } + return deserialized # type: ignore @distributed_trace_async async def begin_create( @@ -125,8 +133,8 @@ async def begin_create( Create and Associate private link traffic filter for the given deployment. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str @@ -136,14 +144,6 @@ async def begin_create( :type private_endpoint_guid: str :param private_endpoint_name: Name of the private endpoint. Default value is None. :type private_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -157,7 +157,7 @@ async def begin_create( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_initial( # type: ignore + raw_result = await self._create_initial( resource_group_name=resource_group_name, monitor_name=monitor_name, name=name, @@ -169,11 +169,12 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -184,14 +185,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/createAndAssociatePLFilter" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_deployment_info_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_deployment_info_operations.py index 656aa3b649f3..67a8b2965a4f 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_deployment_info_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_deployment_info_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._deployment_info_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,17 +61,16 @@ async def list(self, resource_group_name: str, monitor_name: str, **kwargs: Any) Fetch information regarding Elastic cloud deployment corresponding to the Elastic monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeploymentInfoResponse or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.DeploymentInfoResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,21 +84,19 @@ async def list(self, resource_group_name: str, monitor_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DeploymentInfoResponse] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, monitor_name=monitor_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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -108,13 +108,9 @@ async def list(self, resource_group_name: str, monitor_name: str, **kwargs: Any) ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DeploymentInfoResponse", pipeline_response) + deserialized = self._deserialize("DeploymentInfoResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/listDeploymentInfo" - } + return deserialized # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_detach_and_delete_traffic_filter_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_detach_and_delete_traffic_filter_operations.py index d4f699e9601b..44f0c46daf60 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_detach_and_delete_traffic_filter_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_detach_and_delete_traffic_filter_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._detach_and_delete_traffic_filter_operations import build_delete_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,19 +61,18 @@ async def delete( # pylint: disable=inconsistent-return-statements Detach and Delete traffic filter from the given deployment. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param ruleset_id: Ruleset Id of the filter. Default value is None. :type ruleset_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -84,22 +86,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, ruleset_id=ruleset_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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -112,8 +112,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/detachAndDeleteTrafficFilter" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_detach_traffic_filter_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_detach_traffic_filter_operations.py index 86c526788c2a..1d7ca8c993d1 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_detach_traffic_filter_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_detach_traffic_filter_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterator, Callable, Dict, Optional, Type, TypeVar, Union, cast from azure.core.exceptions import ( ClientAuthenticationError, @@ -14,21 +15,25 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._detach_traffic_filter_operations import build_update_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -52,10 +57,10 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = 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 _update_initial( # pylint: disable=inconsistent-return-statements + async def _update_initial( self, resource_group_name: str, monitor_name: str, ruleset_id: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -67,41 +72,44 @@ async def _update_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, ruleset_id=ruleset_id, api_version=api_version, - 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( _models.ResourceProviderDefaultErrorResponse, pipeline_response ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/detachTrafficFilter" - } + return deserialized # type: ignore @distributed_trace_async async def begin_update( @@ -111,21 +119,13 @@ async def begin_update( Detach traffic filter for the given deployment. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param ruleset_id: Ruleset Id of the filter. Default value is None. :type ruleset_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -139,7 +139,7 @@ async def begin_update( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._update_initial( # type: ignore + raw_result = await self._update_initial( resource_group_name=resource_group_name, monitor_name=monitor_name, ruleset_id=ruleset_id, @@ -149,11 +149,12 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -164,14 +165,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/detachTrafficFilter" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_elastic_versions_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_elastic_versions_operations.py index f0891cb7a129..c55d5473f9ef 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_elastic_versions_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_elastic_versions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._elastic_versions_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -60,7 +63,6 @@ def list(self, region: str, **kwargs: Any) -> AsyncIterable["_models.ElasticVers :param region: Region where elastic deployment will take place. Required. :type region: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ElasticVersionListFormat or the result of cls(response) :rtype: @@ -73,7 +75,7 @@ def list(self, region: str, **kwargs: Any) -> AsyncIterable["_models.ElasticVers api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticVersionsListResponse] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -84,16 +86,14 @@ def list(self, region: str, **kwargs: Any) -> AsyncIterable["_models.ElasticVers def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, region=region, 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) else: # make call to next link with the client's api-version @@ -105,13 +105,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ElasticVersionsListResponse", pipeline_response) @@ -121,11 +120,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -139,5 +138,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Elastic/elasticVersions"} diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_external_user_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_external_user_operations.py index 2732c78deee9..bbe670027f5e 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_external_user_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_external_user_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._external_user_operations import build_create_or_update_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -66,8 +70,8 @@ async def create_or_update( Create User inside elastic deployment which are used by customers to perform operations on the elastic deployment. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str @@ -76,7 +80,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ExternalUserCreationResponse or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.ExternalUserCreationResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -87,7 +90,7 @@ async def create_or_update( self, resource_group_name: str, monitor_name: str, - body: Optional[IO] = None, + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -98,17 +101,16 @@ async def create_or_update( Create User inside elastic deployment which are used by customers to perform operations on the elastic deployment. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param body: Elastic External User Creation Parameters. Default value is None. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ExternalUserCreationResponse or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.ExternalUserCreationResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -119,7 +121,7 @@ async def create_or_update( self, resource_group_name: str, monitor_name: str, - body: Optional[Union[_models.ExternalUserInfo, IO]] = None, + body: Optional[Union[_models.ExternalUserInfo, IO[bytes]]] = None, **kwargs: Any ) -> _models.ExternalUserCreationResponse: """Create User inside elastic deployment which are used by customers to perform operations on the @@ -128,23 +130,19 @@ async def create_or_update( Create User inside elastic deployment which are used by customers to perform operations on the elastic deployment. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param body: Elastic External User Creation Parameters. Is either a ExternalUserInfo type or a - IO type. Default value is None. - :type body: ~azure.mgmt.elastic.models.ExternalUserInfo or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.elastic.models.ExternalUserInfo or IO[bytes] :return: ExternalUserCreationResponse or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.ExternalUserCreationResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -162,7 +160,7 @@ async def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: if body is not None: @@ -170,7 +168,7 @@ async def create_or_update( else: _json = None - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, @@ -178,16 +176,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -199,13 +195,9 @@ async def create_or_update( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ExternalUserCreationResponse", pipeline_response) + deserialized = self._deserialize("ExternalUserCreationResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/createOrUpdateExternalUser" - } + return deserialized # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_list_associated_traffic_filters_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_list_associated_traffic_filters_operations.py index 6c666aa90711..dc896a6f4a9b 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_list_associated_traffic_filters_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_list_associated_traffic_filters_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._list_associated_traffic_filters_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,17 +61,16 @@ async def list( Get the list of all associated traffic filters for the given deployment. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ElasticTrafficFilterResponse or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.ElasticTrafficFilterResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,21 +84,19 @@ async def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticTrafficFilterResponse] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, monitor_name=monitor_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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -108,13 +108,9 @@ async def list( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ElasticTrafficFilterResponse", pipeline_response) + deserialized = self._deserialize("ElasticTrafficFilterResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/listAssociatedTrafficFilters" - } + return deserialized # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_monitor_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_monitor_operations.py index 244aad40ab59..ddd1e5cd0380 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_monitor_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_monitor_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from io import IOBase +import sys +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -14,21 +16,25 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._monitor_operations import build_upgrade_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -52,14 +58,14 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = 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 _upgrade_initial( # pylint: disable=inconsistent-return-statements + async def _upgrade_initial( self, resource_group_name: str, monitor_name: str, - body: Optional[Union[_models.ElasticMonitorUpgrade, IO]] = None, + body: Optional[Union[_models.ElasticMonitorUpgrade, IO[bytes]]] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -72,12 +78,12 @@ async def _upgrade_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: if body is not None: @@ -85,7 +91,7 @@ async def _upgrade_initial( # pylint: disable=inconsistent-return-statements else: _json = None - request = build_upgrade_request( + _request = build_upgrade_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, @@ -93,33 +99,36 @@ async def _upgrade_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self._upgrade_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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( _models.ResourceProviderDefaultErrorResponse, pipeline_response ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _upgrade_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/upgrade" - } + return deserialized # type: ignore @overload async def begin_upgrade( @@ -135,8 +144,8 @@ async def begin_upgrade( Upgradable version for a monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str @@ -145,14 +154,6 @@ async def begin_upgrade( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -163,7 +164,7 @@ async def begin_upgrade( self, resource_group_name: str, monitor_name: str, - body: Optional[IO] = None, + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -172,24 +173,16 @@ async def begin_upgrade( Upgradable version for a monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param body: Elastic Monitor Upgrade Parameters. Default value is None. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -200,32 +193,21 @@ async def begin_upgrade( self, resource_group_name: str, monitor_name: str, - body: Optional[Union[_models.ElasticMonitorUpgrade, IO]] = None, + body: Optional[Union[_models.ElasticMonitorUpgrade, IO[bytes]]] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Upgradable version for a monitor resource. Upgradable version for a monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :param body: Elastic Monitor Upgrade Parameters. Is either a ElasticMonitorUpgrade type or a IO - type. Default value is None. - :type body: ~azure.mgmt.elastic.models.ElasticMonitorUpgrade or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param body: Elastic Monitor Upgrade Parameters. Is either a ElasticMonitorUpgrade type or a + IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.elastic.models.ElasticMonitorUpgrade or IO[bytes] :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -240,7 +222,7 @@ async def begin_upgrade( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._upgrade_initial( # type: ignore + raw_result = await self._upgrade_initial( resource_group_name=resource_group_name, monitor_name=monitor_name, body=body, @@ -251,11 +233,12 @@ async def begin_upgrade( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -264,14 +247,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_upgrade.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/upgrade" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_monitored_resources_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_monitored_resources_operations.py index 8a5d4b92d330..376efeccb0bc 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_monitored_resources_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_monitored_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._monitored_resources_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -60,12 +63,11 @@ def list( List the resources currently being monitored by the Elastic monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MonitoredResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elastic.models.MonitoredResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -76,7 +78,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MonitoredResourceListResponse] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -87,17 +89,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, monitor_name=monitor_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) else: # make call to next link with the client's api-version @@ -109,13 +109,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("MonitoredResourceListResponse", pipeline_response) @@ -125,11 +124,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -143,7 +142,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/listMonitoredResources" - } diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_monitored_subscriptions_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_monitored_subscriptions_operations.py new file mode 100644 index 000000000000..17954a231f92 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_monitored_subscriptions_operations.py @@ -0,0 +1,773 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._monitored_subscriptions_operations import ( + build_createor_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class MonitoredSubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elastic.aio.MicrosoftElastic`'s + :attr:`monitored_subscriptions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, monitor_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MonitoredSubscriptionProperties"]: + """List all the subscriptions currently being monitored by the Elastic monitor resource. + + List all the subscriptions currently being monitored by the Elastic monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :return: An iterator like instance of either MonitoredSubscriptionProperties or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elastic.models.MonitoredSubscriptionProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.MonitoredSubscriptionPropertiesList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("MonitoredSubscriptionPropertiesList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, monitor_name: str, configuration_name: str, **kwargs: Any + ) -> _models.MonitoredSubscriptionProperties: + """List all the subscriptions currently being monitored by the Elastic monitor resource. + + List all the subscriptions currently being monitored by the Elastic monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param configuration_name: The configuration name. Only 'default' value is supported. Required. + :type configuration_name: str + :return: MonitoredSubscriptionProperties or the result of cls(response) + :rtype: ~azure.mgmt.elastic.models.MonitoredSubscriptionProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.MonitoredSubscriptionProperties] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MonitoredSubscriptionProperties", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _createor_update_initial( + self, + resource_group_name: str, + monitor_name: str, + configuration_name: str, + body: Optional[Union[_models.MonitoredSubscriptionProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "MonitoredSubscriptionProperties") + else: + _json = None + + _request = build_createor_update_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_createor_update( + self, + resource_group_name: str, + monitor_name: str, + configuration_name: str, + body: Optional[_models.MonitoredSubscriptionProperties] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoredSubscriptionProperties]: + """Add the subscriptions that should be monitored by the Elastic monitor resource. + + Add the subscriptions that should be monitored by the Elastic monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param configuration_name: The configuration name. Only 'default' value is supported. Required. + :type configuration_name: str + :param body: Default value is None. + :type body: ~azure.mgmt.elastic.models.MonitoredSubscriptionProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either MonitoredSubscriptionProperties or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elastic.models.MonitoredSubscriptionProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_createor_update( + self, + resource_group_name: str, + monitor_name: str, + configuration_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoredSubscriptionProperties]: + """Add the subscriptions that should be monitored by the Elastic monitor resource. + + Add the subscriptions that should be monitored by the Elastic monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param configuration_name: The configuration name. Only 'default' value is supported. Required. + :type configuration_name: str + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either MonitoredSubscriptionProperties or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elastic.models.MonitoredSubscriptionProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_createor_update( + self, + resource_group_name: str, + monitor_name: str, + configuration_name: str, + body: Optional[Union[_models.MonitoredSubscriptionProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoredSubscriptionProperties]: + """Add the subscriptions that should be monitored by the Elastic monitor resource. + + Add the subscriptions that should be monitored by the Elastic monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param configuration_name: The configuration name. Only 'default' value is supported. Required. + :type configuration_name: str + :param body: Is either a MonitoredSubscriptionProperties type or a IO[bytes] type. Default + value is None. + :type body: ~azure.mgmt.elastic.models.MonitoredSubscriptionProperties or IO[bytes] + :return: An instance of AsyncLROPoller that returns either MonitoredSubscriptionProperties or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elastic.models.MonitoredSubscriptionProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MonitoredSubscriptionProperties] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._createor_update_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + configuration_name=configuration_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("MonitoredSubscriptionProperties", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.MonitoredSubscriptionProperties].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.MonitoredSubscriptionProperties]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + monitor_name: str, + configuration_name: str, + body: Optional[Union[_models.MonitoredSubscriptionProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "MonitoredSubscriptionProperties") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + monitor_name: str, + configuration_name: str, + body: Optional[_models.MonitoredSubscriptionProperties] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoredSubscriptionProperties]: + """Updates the subscriptions that are being monitored by the Elastic monitor resource. + + Updates the subscriptions that are being monitored by the Elastic monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param configuration_name: The configuration name. Only 'default' value is supported. Required. + :type configuration_name: str + :param body: Default value is None. + :type body: ~azure.mgmt.elastic.models.MonitoredSubscriptionProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either MonitoredSubscriptionProperties or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elastic.models.MonitoredSubscriptionProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + monitor_name: str, + configuration_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoredSubscriptionProperties]: + """Updates the subscriptions that are being monitored by the Elastic monitor resource. + + Updates the subscriptions that are being monitored by the Elastic monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param configuration_name: The configuration name. Only 'default' value is supported. Required. + :type configuration_name: str + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either MonitoredSubscriptionProperties or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elastic.models.MonitoredSubscriptionProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + monitor_name: str, + configuration_name: str, + body: Optional[Union[_models.MonitoredSubscriptionProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoredSubscriptionProperties]: + """Updates the subscriptions that are being monitored by the Elastic monitor resource. + + Updates the subscriptions that are being monitored by the Elastic monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param configuration_name: The configuration name. Only 'default' value is supported. Required. + :type configuration_name: str + :param body: Is either a MonitoredSubscriptionProperties type or a IO[bytes] type. Default + value is None. + :type body: ~azure.mgmt.elastic.models.MonitoredSubscriptionProperties or IO[bytes] + :return: An instance of AsyncLROPoller that returns either MonitoredSubscriptionProperties or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elastic.models.MonitoredSubscriptionProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MonitoredSubscriptionProperties] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + configuration_name=configuration_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("MonitoredSubscriptionProperties", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.MonitoredSubscriptionProperties].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.MonitoredSubscriptionProperties]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, monitor_name: str, configuration_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, monitor_name: str, configuration_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the subscriptions that are being monitored by the Elastic monitor resource. + + Updates the subscriptions that are being monitored by the Elastic monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param configuration_name: The configuration name. Only 'default' value is supported. Required. + :type configuration_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + configuration_name=configuration_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_monitors_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_monitors_operations.py index a676a7588601..ed1b3a8d47f7 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_monitors_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_monitors_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -16,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -29,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._monitors_operations import ( build_create_request, build_delete_request, @@ -39,6 +41,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +74,6 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ElasticMonitorResource"] List all monitors under the specified subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ElasticMonitorResource or the result of cls(response) :rtype: @@ -81,7 +86,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ElasticMonitorResource"] api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticMonitorResourceListResponse] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -92,15 +97,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ElasticMonitorResource"] def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _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) else: # make call to next link with the client's api-version @@ -112,13 +115,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ElasticMonitorResourceListResponse", pipeline_response) @@ -128,11 +130,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -147,8 +149,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Elastic/monitors"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -157,10 +157,9 @@ def list_by_resource_group( List all monitors under the specified resource group. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ElasticMonitorResource or the result of cls(response) :rtype: @@ -173,7 +172,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticMonitorResourceListResponse] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -184,16 +183,14 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _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) else: # make call to next link with the client's api-version @@ -205,13 +202,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ElasticMonitorResourceListResponse", pipeline_response) @@ -221,11 +217,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -240,27 +236,22 @@ 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.Elastic/monitors" - } - @distributed_trace_async async def get(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> _models.ElasticMonitorResource: """Get the properties of a specific monitor resource. Get the properties of a specific monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ElasticMonitorResource or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.ElasticMonitorResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -274,21 +265,19 @@ async def get(self, resource_group_name: str, monitor_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticMonitorResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, monitor_name=monitor_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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -300,25 +289,21 @@ async def get(self, resource_group_name: str, monitor_name: str, **kwargs: Any) ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ElasticMonitorResource", pipeline_response) + deserialized = self._deserialize("ElasticMonitorResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, monitor_name: str, - body: Optional[Union[_models.ElasticMonitorResource, IO]] = None, + body: Optional[Union[_models.ElasticMonitorResource, IO[bytes]]] = None, **kwargs: Any - ) -> _models.ElasticMonitorResource: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,12 +316,12 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ElasticMonitorResource] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: if body is not None: @@ -344,7 +329,7 @@ async def _create_initial( else: _json = None - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, @@ -352,42 +337,37 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( _models.ResourceProviderDefaultErrorResponse, pipeline_response ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ElasticMonitorResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ElasticMonitorResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}" - } - @overload async def begin_create( self, @@ -402,8 +382,8 @@ async def begin_create( Create a monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str @@ -412,14 +392,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ElasticMonitorResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elastic.models.ElasticMonitorResource] @@ -431,7 +403,7 @@ async def begin_create( self, resource_group_name: str, monitor_name: str, - body: Optional[IO] = None, + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -440,24 +412,16 @@ async def begin_create( Create a monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param body: Elastic monitor resource model. Default value is None. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ElasticMonitorResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elastic.models.ElasticMonitorResource] @@ -469,32 +433,21 @@ async def begin_create( self, resource_group_name: str, monitor_name: str, - body: Optional[Union[_models.ElasticMonitorResource, IO]] = None, + body: Optional[Union[_models.ElasticMonitorResource, IO[bytes]]] = None, **kwargs: Any ) -> AsyncLROPoller[_models.ElasticMonitorResource]: """Create a monitor resource. Create a monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :param body: Elastic monitor resource model. Is either a ElasticMonitorResource type or a IO - type. Default value is None. - :type body: ~azure.mgmt.elastic.models.ElasticMonitorResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param body: Elastic monitor resource model. Is either a ElasticMonitorResource type or a + IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.elastic.models.ElasticMonitorResource or IO[bytes] :return: An instance of AsyncLROPoller that returns either ElasticMonitorResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elastic.models.ElasticMonitorResource] @@ -521,12 +474,13 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ElasticMonitorResource", pipeline_response) + deserialized = self._deserialize("ElasticMonitorResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -539,20 +493,92 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ElasticMonitorResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller[_models.ElasticMonitorResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}" - } + async def _update_initial( + self, + resource_group_name: str, + monitor_name: str, + body: Optional[Union[_models.ElasticMonitorResourceUpdateParameters, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "ElasticMonitorResourceUpdateParameters") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload - async def update( + async def begin_update( self, resource_group_name: str, monitor_name: str, @@ -560,13 +586,13 @@ async def update( *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ElasticMonitorResource: + ) -> AsyncLROPoller[_models.ElasticMonitorResource]: """Update a monitor resource. Update a monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str @@ -575,140 +601,118 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ElasticMonitorResource or the result of cls(response) - :rtype: ~azure.mgmt.elastic.models.ElasticMonitorResource + :return: An instance of AsyncLROPoller that returns either ElasticMonitorResource or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elastic.models.ElasticMonitorResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( + async def begin_update( self, resource_group_name: str, monitor_name: str, - body: Optional[IO] = None, + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ElasticMonitorResource: + ) -> AsyncLROPoller[_models.ElasticMonitorResource]: """Update a monitor resource. Update a monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param body: Elastic resource model update parameters. Default value is None. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ElasticMonitorResource or the result of cls(response) - :rtype: ~azure.mgmt.elastic.models.ElasticMonitorResource + :return: An instance of AsyncLROPoller that returns either ElasticMonitorResource or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elastic.models.ElasticMonitorResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def update( + async def begin_update( self, resource_group_name: str, monitor_name: str, - body: Optional[Union[_models.ElasticMonitorResourceUpdateParameters, IO]] = None, + body: Optional[Union[_models.ElasticMonitorResourceUpdateParameters, IO[bytes]]] = None, **kwargs: Any - ) -> _models.ElasticMonitorResource: + ) -> AsyncLROPoller[_models.ElasticMonitorResource]: """Update a monitor resource. Update a monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param body: Elastic resource model update parameters. Is either a - ElasticMonitorResourceUpdateParameters type or a IO type. Default value is None. - :type body: ~azure.mgmt.elastic.models.ElasticMonitorResourceUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ElasticMonitorResource or the result of cls(response) - :rtype: ~azure.mgmt.elastic.models.ElasticMonitorResource + ElasticMonitorResourceUpdateParameters type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.elastic.models.ElasticMonitorResourceUpdateParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either ElasticMonitorResource or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elastic.models.ElasticMonitorResource] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ElasticMonitorResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "ElasticMonitorResourceUpdateParameters") - else: - _json = None - - request = build_update_request( - resource_group_name=resource_group_name, - monitor_name=monitor_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ResourceProviderDefaultErrorResponse, pipeline_response + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ElasticMonitorResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - return deserialized + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ElasticMonitorResource", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}" - } + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ElasticMonitorResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ElasticMonitorResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, monitor_name: str, **kwargs: Any - ) -> None: - error_map = { + async def _delete_initial(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -720,40 +724,43 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, monitor_name=monitor_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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( _models.ResourceProviderDefaultErrorResponse, pipeline_response ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -761,19 +768,11 @@ async def begin_delete(self, resource_group_name: str, monitor_name: str, **kwar Delete a monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -787,7 +786,7 @@ async def begin_delete(self, resource_group_name: str, monitor_name: str, **kwar lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, monitor_name=monitor_name, api_version=api_version, @@ -796,11 +795,12 @@ async def begin_delete(self, resource_group_name: str, monitor_name: str, **kwar params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -809,14 +809,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_open_ai_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_open_ai_operations.py new file mode 100644 index 000000000000..5537bc725259 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_open_ai_operations.py @@ -0,0 +1,497 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._open_ai_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_get_status_request, + build_list_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class OpenAIOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elastic.aio.MicrosoftElastic`'s + :attr:`open_ai` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, monitor_name: str, **kwargs: Any + ) -> AsyncIterable["_models.OpenAIIntegrationRPModel"]: + """List OpenAI integration rule for a given monitor resource. + + List OpenAI integration rule for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :return: An iterator like instance of either OpenAIIntegrationRPModel or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elastic.models.OpenAIIntegrationRPModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OpenAIIntegrationRPModelListResponse] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OpenAIIntegrationRPModelListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ResourceProviderDefaultErrorResponse, pipeline_response + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, monitor_name: str, integration_name: str, **kwargs: Any + ) -> _models.OpenAIIntegrationRPModel: + """Get OpenAI integration rule for a given monitor resource. + + Get OpenAI integration rule for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param integration_name: OpenAI Integration name. Required. + :type integration_name: str + :return: OpenAIIntegrationRPModel or the result of cls(response) + :rtype: ~azure.mgmt.elastic.models.OpenAIIntegrationRPModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OpenAIIntegrationRPModel] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + integration_name=integration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ResourceProviderDefaultErrorResponse, pipeline_response + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OpenAIIntegrationRPModel", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + monitor_name: str, + integration_name: str, + body: Optional[_models.OpenAIIntegrationRPModel] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.OpenAIIntegrationRPModel: + """Create or update a OpenAI integration rule for a given monitor resource. + + Create or update a OpenAI integration rule for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param integration_name: OpenAI Integration name. Required. + :type integration_name: str + :param body: Default value is None. + :type body: ~azure.mgmt.elastic.models.OpenAIIntegrationRPModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: OpenAIIntegrationRPModel or the result of cls(response) + :rtype: ~azure.mgmt.elastic.models.OpenAIIntegrationRPModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + monitor_name: str, + integration_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.OpenAIIntegrationRPModel: + """Create or update a OpenAI integration rule for a given monitor resource. + + Create or update a OpenAI integration rule for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param integration_name: OpenAI Integration name. Required. + :type integration_name: str + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: OpenAIIntegrationRPModel or the result of cls(response) + :rtype: ~azure.mgmt.elastic.models.OpenAIIntegrationRPModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + monitor_name: str, + integration_name: str, + body: Optional[Union[_models.OpenAIIntegrationRPModel, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.OpenAIIntegrationRPModel: + """Create or update a OpenAI integration rule for a given monitor resource. + + Create or update a OpenAI integration rule for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param integration_name: OpenAI Integration name. Required. + :type integration_name: str + :param body: Is either a OpenAIIntegrationRPModel type or a IO[bytes] type. Default value is + None. + :type body: ~azure.mgmt.elastic.models.OpenAIIntegrationRPModel or IO[bytes] + :return: OpenAIIntegrationRPModel or the result of cls(response) + :rtype: ~azure.mgmt.elastic.models.OpenAIIntegrationRPModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenAIIntegrationRPModel] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "OpenAIIntegrationRPModel") + else: + _json = None + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + integration_name=integration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ResourceProviderDefaultErrorResponse, pipeline_response + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OpenAIIntegrationRPModel", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, monitor_name: str, integration_name: str, **kwargs: Any + ) -> None: + """Delete OpenAI integration rule for a given monitor resource. + + Delete OpenAI integration rule for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param integration_name: OpenAI Integration name. Required. + :type integration_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + integration_name=integration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ResourceProviderDefaultErrorResponse, pipeline_response + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def get_status( + self, resource_group_name: str, monitor_name: str, integration_name: str, **kwargs: Any + ) -> _models.OpenAIIntegrationStatusResponse: + """Get OpenAI integration status for a given integration. + + Get OpenAI integration status for a given integration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param integration_name: OpenAI Integration name. Required. + :type integration_name: str + :return: OpenAIIntegrationStatusResponse or the result of cls(response) + :rtype: ~azure.mgmt.elastic.models.OpenAIIntegrationStatusResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OpenAIIntegrationStatusResponse] = kwargs.pop("cls", None) + + _request = build_get_status_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + integration_name=integration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ResourceProviderDefaultErrorResponse, pipeline_response + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OpenAIIntegrationStatusResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_operations.py index e43c99f0e8b4..4ef4c0f0d0c8 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,7 +61,6 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationResult"]: List all operations provided by Microsoft.Elastic. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationResult or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elastic.models.OperationResult] :raises ~azure.core.exceptions.HttpResponseError: @@ -69,7 +71,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationResult"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,14 +82,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationResult"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _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) else: # make call to next link with the client's api-version @@ -99,13 +99,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -115,11 +114,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -133,5 +132,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Elastic/operations"} diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_organizations_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_organizations_operations.py index c0672c22373c..fbfa8eafb705 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_organizations_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_organizations_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from io import IOBase +import sys +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -14,19 +16,29 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request -from ...operations._organizations_operations import build_get_api_key_request +from ...operations._organizations_operations import ( + build_get_api_key_request, + build_get_elastic_to_azure_subscription_mapping_request, + build_resubscribe_request, +) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -66,7 +78,6 @@ async def get_api_key( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: UserApiKeyResponse or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.UserApiKeyResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -74,7 +85,7 @@ async def get_api_key( @overload async def get_api_key( - self, body: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any + self, body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any ) -> _models.UserApiKeyResponse: """Fetch User API Key from internal database, if it was generated and stored while creating the Elasticsearch Organization. @@ -84,11 +95,10 @@ async def get_api_key( :param body: Email Id parameter of the User Organization, of which the API Key must be returned. Default value is None. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: UserApiKeyResponse or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.UserApiKeyResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -96,7 +106,7 @@ async def get_api_key( @distributed_trace_async async def get_api_key( - self, body: Optional[Union[_models.UserEmailId, IO]] = None, **kwargs: Any + self, body: Optional[Union[_models.UserEmailId, IO[bytes]]] = None, **kwargs: Any ) -> _models.UserApiKeyResponse: """Fetch User API Key from internal database, if it was generated and stored while creating the Elasticsearch Organization. @@ -105,17 +115,13 @@ async def get_api_key( Elasticsearch Organization. :param body: Email Id parameter of the User Organization, of which the API Key must be - returned. Is either a UserEmailId type or a IO type. Default value is None. - :type body: ~azure.mgmt.elastic.models.UserEmailId or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + returned. Is either a UserEmailId type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.elastic.models.UserEmailId or IO[bytes] :return: UserApiKeyResponse or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.UserApiKeyResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -133,7 +139,7 @@ async def get_api_key( content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: if body is not None: @@ -141,22 +147,20 @@ async def get_api_key( else: _json = None - request = build_get_api_key_request( + _request = build_get_api_key_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.get_api_key.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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -168,11 +172,274 @@ async def get_api_key( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("UserApiKeyResponse", pipeline_response) + deserialized = self._deserialize("UserApiKeyResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_elastic_to_azure_subscription_mapping( # pylint: disable=name-too-long + self, **kwargs: Any + ) -> _models.ElasticOrganizationToAzureSubscriptionMappingResponse: + """Get Elastic Organization To Azure Subscription Mapping details for the logged-in user. + + Get Elastic Organization To Azure Subscription Mapping details for the logged-in user. + + :return: ElasticOrganizationToAzureSubscriptionMappingResponse or the result of cls(response) + :rtype: ~azure.mgmt.elastic.models.ElasticOrganizationToAzureSubscriptionMappingResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - return deserialized + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - get_api_key.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Elastic/getOrganizationApiKey"} + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ElasticOrganizationToAzureSubscriptionMappingResponse] = kwargs.pop("cls", None) + + _request = build_get_elastic_to_azure_subscription_mapping_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ResourceProviderDefaultErrorResponse, pipeline_response + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "ElasticOrganizationToAzureSubscriptionMappingResponse", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _resubscribe_initial( + self, + resource_group_name: str, + monitor_name: str, + body: Optional[Union[_models.ResubscribeProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "ResubscribeProperties") + else: + _json = None + + _request = build_resubscribe_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_resubscribe( + self, + resource_group_name: str, + monitor_name: str, + body: Optional[_models.ResubscribeProperties] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ElasticMonitorResource]: + """Resubscribe the Elasticsearch Organization. + + Resubscribe the Elasticsearch Organization. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param body: Resubscribe Properties. Default value is None. + :type body: ~azure.mgmt.elastic.models.ResubscribeProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either ElasticMonitorResource or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elastic.models.ElasticMonitorResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_resubscribe( + self, + resource_group_name: str, + monitor_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ElasticMonitorResource]: + """Resubscribe the Elasticsearch Organization. + + Resubscribe the Elasticsearch Organization. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param body: Resubscribe Properties. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either ElasticMonitorResource or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elastic.models.ElasticMonitorResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_resubscribe( + self, + resource_group_name: str, + monitor_name: str, + body: Optional[Union[_models.ResubscribeProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ElasticMonitorResource]: + """Resubscribe the Elasticsearch Organization. + + Resubscribe the Elasticsearch Organization. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param body: Resubscribe Properties. Is either a ResubscribeProperties type or a IO[bytes] + type. Default value is None. + :type body: ~azure.mgmt.elastic.models.ResubscribeProperties or IO[bytes] + :return: An instance of AsyncLROPoller that returns either ElasticMonitorResource or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elastic.models.ElasticMonitorResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ElasticMonitorResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._resubscribe_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ElasticMonitorResource", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ElasticMonitorResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ElasticMonitorResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_tag_rules_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_tag_rules_operations.py index e8b5c5f9fd16..5997a419ea8f 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_tag_rules_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_tag_rules_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -16,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -29,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._tag_rules_operations import ( build_create_or_update_request, build_delete_request, @@ -37,6 +39,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,12 +74,11 @@ def list( List the tag rules for a given monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MonitoringTagRules or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elastic.models.MonitoringTagRules] :raises ~azure.core.exceptions.HttpResponseError: @@ -84,7 +89,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MonitoringTagRulesListResponse] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,17 +100,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, monitor_name=monitor_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) else: # make call to next link with the client's api-version @@ -117,13 +120,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("MonitoringTagRulesListResponse", pipeline_response) @@ -133,11 +135,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -152,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/tagRules" - } - @overload async def create_or_update( self, @@ -171,8 +169,8 @@ async def create_or_update( Create or update a tag rule set for a given monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str @@ -183,7 +181,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: MonitoringTagRules or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.MonitoringTagRules :raises ~azure.core.exceptions.HttpResponseError: @@ -195,7 +192,7 @@ async def create_or_update( resource_group_name: str, monitor_name: str, rule_set_name: str, - body: Optional[IO] = None, + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -204,19 +201,18 @@ async def create_or_update( Create or update a tag rule set for a given monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param rule_set_name: Tag Rule Set resource name. Required. :type rule_set_name: str :param body: request body of MonitoringTagRules. Default value is None. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: MonitoringTagRules or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.MonitoringTagRules :raises ~azure.core.exceptions.HttpResponseError: @@ -228,32 +224,28 @@ async def create_or_update( resource_group_name: str, monitor_name: str, rule_set_name: str, - body: Optional[Union[_models.MonitoringTagRules, IO]] = None, + body: Optional[Union[_models.MonitoringTagRules, IO[bytes]]] = None, **kwargs: Any ) -> _models.MonitoringTagRules: """Create or update a tag rule set for a given monitor resource. Create or update a tag rule set for a given monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param rule_set_name: Tag Rule Set resource name. Required. :type rule_set_name: str - :param body: request body of MonitoringTagRules. Is either a MonitoringTagRules type or a IO - type. Default value is None. - :type body: ~azure.mgmt.elastic.models.MonitoringTagRules or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param body: request body of MonitoringTagRules. Is either a MonitoringTagRules type or a + IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.elastic.models.MonitoringTagRules or IO[bytes] :return: MonitoringTagRules or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.MonitoringTagRules :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -271,7 +263,7 @@ async def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: if body is not None: @@ -279,7 +271,7 @@ async def create_or_update( else: _json = None - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, monitor_name=monitor_name, rule_set_name=rule_set_name, @@ -288,16 +280,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -309,16 +299,12 @@ async def create_or_update( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MonitoringTagRules", pipeline_response) + deserialized = self._deserialize("MonitoringTagRules", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/tagRules/{ruleSetName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -328,19 +314,18 @@ async def get( Get a tag rule set for a given monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param rule_set_name: Tag Rule Set resource name. Required. :type rule_set_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: MonitoringTagRules or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.MonitoringTagRules :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -354,22 +339,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MonitoringTagRules] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, monitor_name=monitor_name, rule_set_name=rule_set_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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -381,21 +364,17 @@ async def get( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MonitoringTagRules", pipeline_response) + deserialized = self._deserialize("MonitoringTagRules", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/tagRules/{ruleSetName}" - } + return deserialized # type: ignore - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, monitor_name: str, rule_set_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -407,41 +386,44 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, monitor_name=monitor_name, rule_set_name=rule_set_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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( _models.ResourceProviderDefaultErrorResponse, pipeline_response ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/tagRules/{ruleSetName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -451,21 +433,13 @@ async def begin_delete( Delete a tag rule set for a given monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param rule_set_name: Tag Rule Set resource name. Required. :type rule_set_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -479,7 +453,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, monitor_name=monitor_name, rule_set_name=rule_set_name, @@ -489,11 +463,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -502,14 +477,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/tagRules/{ruleSetName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_traffic_filters_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_traffic_filters_operations.py index 0af6ea7fbeef..5ed5c2ee55bf 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_traffic_filters_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_traffic_filters_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._traffic_filters_operations import build_delete_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,19 +61,18 @@ async def delete( # pylint: disable=inconsistent-return-statements Delete traffic filter from the account. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param ruleset_id: Ruleset Id of the filter. Default value is None. :type ruleset_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -84,22 +86,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, ruleset_id=ruleset_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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -112,8 +112,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/deleteTrafficFilter" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_upgradable_versions_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_upgradable_versions_operations.py index 98d985766d00..61fc5593e891 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_upgradable_versions_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_upgradable_versions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._upgradable_versions_operations import build_details_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,17 +61,16 @@ async def details( List of upgradable versions for a given monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: UpgradableVersionsList or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.UpgradableVersionsList :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,21 +84,19 @@ async def details( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UpgradableVersionsList] = kwargs.pop("cls", None) - request = build_details_request( + _request = build_details_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.details.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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -108,13 +108,9 @@ async def details( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("UpgradableVersionsList", pipeline_response) + deserialized = self._deserialize("UpgradableVersionsList", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - details.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/listUpgradableVersions" - } + return deserialized # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_vm_collection_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_vm_collection_operations.py index 72b9d859f5ab..8b0ccf3c67d1 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_vm_collection_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_vm_collection_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._vm_collection_operations import build_update_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -64,8 +68,8 @@ async def update( # pylint: disable=inconsistent-return-statements Update the vm details that will be monitored by the Elastic monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str @@ -74,7 +78,6 @@ async def update( # pylint: disable=inconsistent-return-statements :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -85,7 +88,7 @@ async def update( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, monitor_name: str, - body: Optional[IO] = None, + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -94,17 +97,16 @@ async def update( # pylint: disable=inconsistent-return-statements Update the vm details that will be monitored by the Elastic monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param body: VM resource Id. Default value is None. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -115,30 +117,26 @@ async def update( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, monitor_name: str, - body: Optional[Union[_models.VMCollectionUpdate, IO]] = None, + body: Optional[Union[_models.VMCollectionUpdate, IO[bytes]]] = None, **kwargs: Any ) -> None: """Update the vm details that will be monitored by the Elastic monitor resource. Update the vm details that will be monitored by the Elastic monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :param body: VM resource Id. Is either a VMCollectionUpdate type or a IO type. Default value is - None. - :type body: ~azure.mgmt.elastic.models.VMCollectionUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param body: VM resource Id. Is either a VMCollectionUpdate type or a IO[bytes] type. Default + value is None. + :type body: ~azure.mgmt.elastic.models.VMCollectionUpdate or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -156,7 +154,7 @@ async def update( # pylint: disable=inconsistent-return-statements content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: if body is not None: @@ -164,7 +162,7 @@ async def update( # pylint: disable=inconsistent-return-statements else: _json = None - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, @@ -172,16 +170,14 @@ async def update( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -194,8 +190,4 @@ async def update( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/vmCollectionUpdate" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_vm_host_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_vm_host_operations.py index d6fdd06c7769..05240605c320 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_vm_host_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_vm_host_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._vm_host_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,12 +61,11 @@ def list(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> As List the vm resources currently being monitored by the Elastic monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VMResources or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elastic.models.VMResources] :raises ~azure.core.exceptions.HttpResponseError: @@ -74,7 +76,7 @@ def list(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> As api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VMHostListResponse] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -85,17 +87,15 @@ def list(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, monitor_name=monitor_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) else: # make call to next link with the client's api-version @@ -107,13 +107,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("VMHostListResponse", pipeline_response) @@ -123,11 +122,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -141,7 +140,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/listVMHost" - } diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_vm_ingestion_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_vm_ingestion_operations.py index 5d3fef056051..d0a726a92fb5 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_vm_ingestion_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/aio/operations/_vm_ingestion_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._vm_ingestion_operations import build_details_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,17 +61,16 @@ async def details( List the vm ingestion details that will be monitored by the Elastic monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: VMIngestionDetailsResponse or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.VMIngestionDetailsResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,21 +84,19 @@ async def details( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VMIngestionDetailsResponse] = kwargs.pop("cls", None) - request = build_details_request( + _request = build_details_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.details.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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -108,13 +108,9 @@ async def details( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("VMIngestionDetailsResponse", pipeline_response) + deserialized = self._deserialize("VMIngestionDetailsResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - details.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/vmIngestionDetails" - } + return deserialized # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/models/__init__.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/models/__init__.py index 21f1938cbe84..e7cb4bb33964 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/models/__init__.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/models/__init__.py @@ -6,7 +6,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from ._models_py3 import BillingInfoResponse from ._models_py3 import CompanyInfo +from ._models_py3 import ConnectedPartnerResourceProperties +from ._models_py3 import ConnectedPartnerResourcesListFormat +from ._models_py3 import ConnectedPartnerResourcesListResponse from ._models_py3 import DeploymentInfoResponse from ._models_py3 import ElasticCloudDeployment from ._models_py3 import ElasticCloudUser @@ -14,6 +18,8 @@ from ._models_py3 import ElasticMonitorResourceListResponse from ._models_py3 import ElasticMonitorResourceUpdateParameters from ._models_py3 import ElasticMonitorUpgrade +from ._models_py3 import ElasticOrganizationToAzureSubscriptionMappingResponse +from ._models_py3 import ElasticOrganizationToAzureSubscriptionMappingResponseProperties from ._models_py3 import ElasticProperties from ._models_py3 import ElasticTrafficFilter from ._models_py3 import ElasticTrafficFilterResponse @@ -21,6 +27,9 @@ from ._models_py3 import ElasticVersionListFormat from ._models_py3 import ElasticVersionListProperties from ._models_py3 import ElasticVersionsListResponse +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse from ._models_py3 import ErrorResponseBody from ._models_py3 import ExternalUserCreationResponse from ._models_py3 import ExternalUserInfo @@ -32,14 +41,26 @@ from ._models_py3 import MonitorProperties from ._models_py3 import MonitoredResource from ._models_py3 import MonitoredResourceListResponse +from ._models_py3 import MonitoredSubscription +from ._models_py3 import MonitoredSubscriptionProperties +from ._models_py3 import MonitoredSubscriptionPropertiesList from ._models_py3 import MonitoringTagRules from ._models_py3 import MonitoringTagRulesListResponse from ._models_py3 import MonitoringTagRulesProperties +from ._models_py3 import OpenAIIntegrationProperties +from ._models_py3 import OpenAIIntegrationRPModel +from ._models_py3 import OpenAIIntegrationRPModelListResponse +from ._models_py3 import OpenAIIntegrationStatusResponse +from ._models_py3 import OpenAIIntegrationStatusResponseProperties from ._models_py3 import OperationDisplay from ._models_py3 import OperationListResult from ._models_py3 import OperationResult +from ._models_py3 import PartnerBillingEntity +from ._models_py3 import PlanDetails from ._models_py3 import ResourceProviderDefaultErrorResponse from ._models_py3 import ResourceSku +from ._models_py3 import ResubscribeProperties +from ._models_py3 import SubscriptionList from ._models_py3 import SystemData from ._models_py3 import UpgradableVersionsList from ._models_py3 import UserApiKeyResponse @@ -56,9 +77,11 @@ from ._microsoft_elastic_enums import LiftrResourceCategories from ._microsoft_elastic_enums import ManagedIdentityTypes from ._microsoft_elastic_enums import MonitoringStatus +from ._microsoft_elastic_enums import Operation from ._microsoft_elastic_enums import OperationName from ._microsoft_elastic_enums import ProvisioningState from ._microsoft_elastic_enums import SendingLogs +from ._microsoft_elastic_enums import Status from ._microsoft_elastic_enums import TagAction from ._microsoft_elastic_enums import Type from ._patch import __all__ as _patch_all @@ -66,7 +89,11 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ + "BillingInfoResponse", "CompanyInfo", + "ConnectedPartnerResourceProperties", + "ConnectedPartnerResourcesListFormat", + "ConnectedPartnerResourcesListResponse", "DeploymentInfoResponse", "ElasticCloudDeployment", "ElasticCloudUser", @@ -74,6 +101,8 @@ "ElasticMonitorResourceListResponse", "ElasticMonitorResourceUpdateParameters", "ElasticMonitorUpgrade", + "ElasticOrganizationToAzureSubscriptionMappingResponse", + "ElasticOrganizationToAzureSubscriptionMappingResponseProperties", "ElasticProperties", "ElasticTrafficFilter", "ElasticTrafficFilterResponse", @@ -81,6 +110,9 @@ "ElasticVersionListFormat", "ElasticVersionListProperties", "ElasticVersionsListResponse", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", "ErrorResponseBody", "ExternalUserCreationResponse", "ExternalUserInfo", @@ -92,14 +124,26 @@ "MonitorProperties", "MonitoredResource", "MonitoredResourceListResponse", + "MonitoredSubscription", + "MonitoredSubscriptionProperties", + "MonitoredSubscriptionPropertiesList", "MonitoringTagRules", "MonitoringTagRulesListResponse", "MonitoringTagRulesProperties", + "OpenAIIntegrationProperties", + "OpenAIIntegrationRPModel", + "OpenAIIntegrationRPModelListResponse", + "OpenAIIntegrationStatusResponse", + "OpenAIIntegrationStatusResponseProperties", "OperationDisplay", "OperationListResult", "OperationResult", + "PartnerBillingEntity", + "PlanDetails", "ResourceProviderDefaultErrorResponse", "ResourceSku", + "ResubscribeProperties", + "SubscriptionList", "SystemData", "UpgradableVersionsList", "UserApiKeyResponse", @@ -115,9 +159,11 @@ "LiftrResourceCategories", "ManagedIdentityTypes", "MonitoringStatus", + "Operation", "OperationName", "ProvisioningState", "SendingLogs", + "Status", "TagAction", "Type", ] diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/models/_microsoft_elastic_enums.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/models/_microsoft_elastic_enums.py index bdb8db0b2e09..ddf60fa4b1b8 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/models/_microsoft_elastic_enums.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/models/_microsoft_elastic_enums.py @@ -46,6 +46,16 @@ class MonitoringStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): DISABLED = "Disabled" +class Operation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operation for the patch on the resource.""" + + ADD_BEGIN = "AddBegin" + ADD_COMPLETE = "AddComplete" + DELETE_BEGIN = "DeleteBegin" + DELETE_COMPLETE = "DeleteComplete" + ACTIVE = "Active" + + class OperationName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Operation to be performed on the given vm resource id.""" @@ -74,6 +84,15 @@ class SendingLogs(str, Enum, metaclass=CaseInsensitiveEnumMeta): FALSE = "False" +class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state of monitoring.""" + + IN_PROGRESS = "InProgress" + ACTIVE = "Active" + FAILED = "Failed" + DELETING = "Deleting" + + class TagAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Valid actions for a filtering tag. Exclusion takes priority over inclusion.""" diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/models/_models_py3.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/models/_models_py3.py index b012b217a9d5..a0b3a92662ec 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/models/_models_py3.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/models/_models_py3.py @@ -17,6 +17,38 @@ from .. import models as _models +class BillingInfoResponse(_serialization.Model): + """Marketplace Subscription and Organization details to which resource gets billed into. + + :ivar marketplace_saas_info: Marketplace Subscription details. + :vartype marketplace_saas_info: ~azure.mgmt.elastic.models.MarketplaceSaaSInfo + :ivar partner_billing_entity: Partner Billing Entity details: Organization Info. + :vartype partner_billing_entity: ~azure.mgmt.elastic.models.PartnerBillingEntity + """ + + _attribute_map = { + "marketplace_saas_info": {"key": "marketplaceSaasInfo", "type": "MarketplaceSaaSInfo"}, + "partner_billing_entity": {"key": "partnerBillingEntity", "type": "PartnerBillingEntity"}, + } + + def __init__( + self, + *, + marketplace_saas_info: Optional["_models.MarketplaceSaaSInfo"] = None, + partner_billing_entity: Optional["_models.PartnerBillingEntity"] = None, + **kwargs: Any + ) -> None: + """ + :keyword marketplace_saas_info: Marketplace Subscription details. + :paramtype marketplace_saas_info: ~azure.mgmt.elastic.models.MarketplaceSaaSInfo + :keyword partner_billing_entity: Partner Billing Entity details: Organization Info. + :paramtype partner_billing_entity: ~azure.mgmt.elastic.models.PartnerBillingEntity + """ + super().__init__(**kwargs) + self.marketplace_saas_info = marketplace_saas_info + self.partner_billing_entity = partner_billing_entity + + class CompanyInfo(_serialization.Model): """Company information of the user to be passed to partners. @@ -33,11 +65,11 @@ class CompanyInfo(_serialization.Model): """ _validation = { - "domain": {"max_length": 250}, - "business": {"max_length": 64}, + "domain": {"max_length": 256}, + "business": {"max_length": 128}, "employees_number": {"max_length": 20}, - "state": {"max_length": 64}, - "country": {"max_length": 64}, + "state": {"max_length": 128}, + "country": {"max_length": 128}, } _attribute_map = { @@ -78,6 +110,107 @@ def __init__( self.country = country +class ConnectedPartnerResourceProperties(_serialization.Model): + """Connected Partner Resource Properties. + + :ivar partner_deployment_name: Elastic deployment name. + :vartype partner_deployment_name: str + :ivar partner_deployment_uri: Deployment URL of the elasticsearch in Elastic cloud deployment. + :vartype partner_deployment_uri: str + :ivar azure_resource_id: The azure resource Id of the deployment. + :vartype azure_resource_id: str + :ivar location: The location of the deployment. + :vartype location: str + """ + + _attribute_map = { + "partner_deployment_name": {"key": "partnerDeploymentName", "type": "str"}, + "partner_deployment_uri": {"key": "partnerDeploymentUri", "type": "str"}, + "azure_resource_id": {"key": "azureResourceId", "type": "str"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__( + self, + *, + partner_deployment_name: Optional[str] = None, + partner_deployment_uri: Optional[str] = None, + azure_resource_id: Optional[str] = None, + location: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword partner_deployment_name: Elastic deployment name. + :paramtype partner_deployment_name: str + :keyword partner_deployment_uri: Deployment URL of the elasticsearch in Elastic cloud + deployment. + :paramtype partner_deployment_uri: str + :keyword azure_resource_id: The azure resource Id of the deployment. + :paramtype azure_resource_id: str + :keyword location: The location of the deployment. + :paramtype location: str + """ + super().__init__(**kwargs) + self.partner_deployment_name = partner_deployment_name + self.partner_deployment_uri = partner_deployment_uri + self.azure_resource_id = azure_resource_id + self.location = location + + +class ConnectedPartnerResourcesListFormat(_serialization.Model): + """Connected Partner Resources List Format. + + :ivar properties: Connected Partner Resource Properties. + :vartype properties: ~azure.mgmt.elastic.models.ConnectedPartnerResourceProperties + """ + + _attribute_map = { + "properties": {"key": "properties", "type": "ConnectedPartnerResourceProperties"}, + } + + def __init__( + self, *, properties: Optional["_models.ConnectedPartnerResourceProperties"] = None, **kwargs: Any + ) -> None: + """ + :keyword properties: Connected Partner Resource Properties. + :paramtype properties: ~azure.mgmt.elastic.models.ConnectedPartnerResourceProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class ConnectedPartnerResourcesListResponse(_serialization.Model): + """List of all active elastic deployments. + + :ivar value: Results of a list operation. + :vartype value: list[~azure.mgmt.elastic.models.ConnectedPartnerResourcesListFormat] + :ivar next_link: Link to the next set of results, if any. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ConnectedPartnerResourcesListFormat]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ConnectedPartnerResourcesListFormat"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Results of a list operation. + :paramtype value: list[~azure.mgmt.elastic.models.ConnectedPartnerResourcesListFormat] + :keyword next_link: Link to the next set of results, if any. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + class DeploymentInfoResponse(_serialization.Model): """The properties of deployment in Elastic cloud corresponding to the Elastic monitor resource. @@ -91,6 +224,9 @@ class DeploymentInfoResponse(_serialization.Model): :vartype memory_capacity: str :ivar disk_capacity: Disk capacity of the elasticsearch in Elastic cloud deployment. :vartype disk_capacity: str + :ivar elasticsearch_end_point: Elasticsearch endpoint in Elastic cloud deployment. This is + either the aliased_endpoint if available, or the service_url otherwise. + :vartype elasticsearch_end_point: str :ivar deployment_url: Deployment URL of the elasticsearch in Elastic cloud deployment. :vartype deployment_url: str :ivar marketplace_saas_info: Marketplace SaaS Info of the resource. @@ -102,6 +238,7 @@ class DeploymentInfoResponse(_serialization.Model): "version": {"readonly": True}, "memory_capacity": {"readonly": True}, "disk_capacity": {"readonly": True}, + "elasticsearch_end_point": {"readonly": True}, "deployment_url": {"readonly": True}, "marketplace_saas_info": {"readonly": True}, } @@ -111,6 +248,7 @@ class DeploymentInfoResponse(_serialization.Model): "version": {"key": "version", "type": "str"}, "memory_capacity": {"key": "memoryCapacity", "type": "str"}, "disk_capacity": {"key": "diskCapacity", "type": "str"}, + "elasticsearch_end_point": {"key": "elasticsearchEndPoint", "type": "str"}, "deployment_url": {"key": "deploymentUrl", "type": "str"}, "marketplace_saas_info": {"key": "marketplaceSaasInfo", "type": "MarketplaceSaaSInfo"}, } @@ -122,6 +260,7 @@ def __init__(self, **kwargs: Any) -> None: self.version = None self.memory_capacity = None self.disk_capacity = None + self.elasticsearch_end_point = None self.deployment_url = None self.marketplace_saas_info = None @@ -218,7 +357,7 @@ class ElasticMonitorResource(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: ARM id of the monitor resource. :vartype id: str @@ -366,6 +505,91 @@ def __init__(self, *, version: Optional[str] = None, **kwargs: Any) -> None: self.version = version +class ElasticOrganizationToAzureSubscriptionMappingResponse(_serialization.Model): # pylint: disable=name-too-long + """The Azure Subscription ID to which the Organization of the logged in user belongs and gets + billed into. + + :ivar properties: The properties of Azure Subscription ID to which the Organization of the + logged in user belongs and gets billed into. + :vartype properties: + ~azure.mgmt.elastic.models.ElasticOrganizationToAzureSubscriptionMappingResponseProperties + """ + + _attribute_map = { + "properties": {"key": "properties", "type": "ElasticOrganizationToAzureSubscriptionMappingResponseProperties"}, + } + + def __init__( + self, + *, + properties: Optional["_models.ElasticOrganizationToAzureSubscriptionMappingResponseProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword properties: The properties of Azure Subscription ID to which the Organization of the + logged in user belongs and gets billed into. + :paramtype properties: + ~azure.mgmt.elastic.models.ElasticOrganizationToAzureSubscriptionMappingResponseProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class ElasticOrganizationToAzureSubscriptionMappingResponseProperties( + _serialization.Model +): # pylint: disable=name-too-long + """The properties of Azure Subscription ID to which the Organization of the logged in user belongs + and gets billed into. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar billed_azure_subscription_id: The Azure Subscription ID to which the Organization belongs + and gets billed into. This is empty for a new user OR a user without an Elastic Organization. + :vartype billed_azure_subscription_id: str + :ivar marketplace_saas_info: Marketplace SaaS Info of the resource. + :vartype marketplace_saas_info: ~azure.mgmt.elastic.models.MarketplaceSaaSInfo + :ivar elastic_organization_id: The Elastic Organization Id. + :vartype elastic_organization_id: str + :ivar elastic_organization_name: The Elastic Organization Name. + :vartype elastic_organization_name: str + """ + + _validation = { + "marketplace_saas_info": {"readonly": True}, + } + + _attribute_map = { + "billed_azure_subscription_id": {"key": "billedAzureSubscriptionId", "type": "str"}, + "marketplace_saas_info": {"key": "marketplaceSaasInfo", "type": "MarketplaceSaaSInfo"}, + "elastic_organization_id": {"key": "elasticOrganizationId", "type": "str"}, + "elastic_organization_name": {"key": "elasticOrganizationName", "type": "str"}, + } + + def __init__( + self, + *, + billed_azure_subscription_id: Optional[str] = None, + elastic_organization_id: Optional[str] = None, + elastic_organization_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword billed_azure_subscription_id: The Azure Subscription ID to which the Organization + belongs and gets billed into. This is empty for a new user OR a user without an Elastic + Organization. + :paramtype billed_azure_subscription_id: str + :keyword elastic_organization_id: The Elastic Organization Id. + :paramtype elastic_organization_id: str + :keyword elastic_organization_name: The Elastic Organization Name. + :paramtype elastic_organization_name: str + """ + super().__init__(**kwargs) + self.billed_azure_subscription_id = billed_azure_subscription_id + self.marketplace_saas_info = None + self.elastic_organization_id = elastic_organization_id + self.elastic_organization_name = elastic_organization_name + + class ElasticProperties(_serialization.Model): """Elastic Resource Properties. @@ -610,6 +834,98 @@ def __init__( self.next_link = next_link +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.elastic.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.elastic.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.elastic.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.elastic.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + class ErrorResponseBody(_serialization.Model): """Error response body. @@ -873,6 +1189,13 @@ class MarketplaceSaaSInfo(_serialization.Model): :vartype marketplace_name: str :ivar marketplace_resource_id: Marketplace Subscription Details: Resource URI. :vartype marketplace_resource_id: str + :ivar marketplace_status: Marketplace Subscription Details: SaaS Subscription Status. + :vartype marketplace_status: str + :ivar billed_azure_subscription_id: The Azure Subscription ID to which the Marketplace + Subscription belongs and gets billed into. + :vartype billed_azure_subscription_id: str + :ivar subscribed: Flag specifying if the Marketplace status is subscribed or not. + :vartype subscribed: bool """ _attribute_map = { @@ -882,6 +1205,9 @@ class MarketplaceSaaSInfo(_serialization.Model): }, "marketplace_name": {"key": "marketplaceName", "type": "str"}, "marketplace_resource_id": {"key": "marketplaceResourceId", "type": "str"}, + "marketplace_status": {"key": "marketplaceStatus", "type": "str"}, + "billed_azure_subscription_id": {"key": "billedAzureSubscriptionId", "type": "str"}, + "subscribed": {"key": "subscribed", "type": "bool"}, } def __init__( @@ -890,6 +1216,9 @@ def __init__( marketplace_subscription: Optional["_models.MarketplaceSaaSInfoMarketplaceSubscription"] = None, marketplace_name: Optional[str] = None, marketplace_resource_id: Optional[str] = None, + marketplace_status: Optional[str] = None, + billed_azure_subscription_id: Optional[str] = None, + subscribed: Optional[bool] = None, **kwargs: Any ) -> None: """ @@ -900,31 +1229,60 @@ def __init__( :paramtype marketplace_name: str :keyword marketplace_resource_id: Marketplace Subscription Details: Resource URI. :paramtype marketplace_resource_id: str + :keyword marketplace_status: Marketplace Subscription Details: SaaS Subscription Status. + :paramtype marketplace_status: str + :keyword billed_azure_subscription_id: The Azure Subscription ID to which the Marketplace + Subscription belongs and gets billed into. + :paramtype billed_azure_subscription_id: str + :keyword subscribed: Flag specifying if the Marketplace status is subscribed or not. + :paramtype subscribed: bool """ super().__init__(**kwargs) self.marketplace_subscription = marketplace_subscription self.marketplace_name = marketplace_name self.marketplace_resource_id = marketplace_resource_id + self.marketplace_status = marketplace_status + self.billed_azure_subscription_id = billed_azure_subscription_id + self.subscribed = subscribed -class MarketplaceSaaSInfoMarketplaceSubscription(_serialization.Model): +class MarketplaceSaaSInfoMarketplaceSubscription(_serialization.Model): # pylint: disable=name-too-long """Marketplace Subscription. :ivar id: Marketplace Subscription Id. This is a GUID-formatted string. :vartype id: str + :ivar publisher_id: Publisher Id of the Marketplace offer. + :vartype publisher_id: str + :ivar offer_id: Offer Id of the Marketplace offer,. + :vartype offer_id: str """ _attribute_map = { "id": {"key": "id", "type": "str"}, + "publisher_id": {"key": "publisherId", "type": "str"}, + "offer_id": {"key": "offerId", "type": "str"}, } - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + publisher_id: Optional[str] = None, + offer_id: Optional[str] = None, + **kwargs: Any + ) -> None: """ :keyword id: Marketplace Subscription Id. This is a GUID-formatted string. :paramtype id: str + :keyword publisher_id: Publisher Id of the Marketplace offer. + :paramtype publisher_id: str + :keyword offer_id: Offer Id of the Marketplace offer,. + :paramtype offer_id: str """ super().__init__(**kwargs) self.id = id + self.publisher_id = publisher_id + self.offer_id = offer_id class MonitoredResource(_serialization.Model): @@ -1002,6 +1360,128 @@ def __init__( self.next_link = next_link +class MonitoredSubscription(_serialization.Model): + """The list of subscriptions and it's monitoring status by current Elastic monitor. + + :ivar subscription_id: The subscriptionId to be monitored. + :vartype subscription_id: str + :ivar status: The state of monitoring. Known values are: "InProgress", "Active", "Failed", and + "Deleting". + :vartype status: str or ~azure.mgmt.elastic.models.Status + :ivar error: The reason of not monitoring the subscription. + :vartype error: str + :ivar tag_rules: Definition of the properties for a TagRules resource. + :vartype tag_rules: ~azure.mgmt.elastic.models.MonitoringTagRulesProperties + """ + + _attribute_map = { + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "error": {"key": "error", "type": "str"}, + "tag_rules": {"key": "tagRules", "type": "MonitoringTagRulesProperties"}, + } + + def __init__( + self, + *, + subscription_id: Optional[str] = None, + status: Optional[Union[str, "_models.Status"]] = None, + error: Optional[str] = None, + tag_rules: Optional["_models.MonitoringTagRulesProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword subscription_id: The subscriptionId to be monitored. + :paramtype subscription_id: str + :keyword status: The state of monitoring. Known values are: "InProgress", "Active", "Failed", + and "Deleting". + :paramtype status: str or ~azure.mgmt.elastic.models.Status + :keyword error: The reason of not monitoring the subscription. + :paramtype error: str + :keyword tag_rules: Definition of the properties for a TagRules resource. + :paramtype tag_rules: ~azure.mgmt.elastic.models.MonitoringTagRulesProperties + """ + super().__init__(**kwargs) + self.subscription_id = subscription_id + self.status = status + self.error = error + self.tag_rules = tag_rules + + +class MonitoredSubscriptionProperties(_serialization.Model): + """The request to update subscriptions needed to be monitored by the Elastic monitor resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the monitored subscription resource. + :vartype name: str + :ivar id: The id of the monitored subscription resource. + :vartype id: str + :ivar type: The type of the monitored subscription resource. + :vartype type: str + :ivar properties: The request to update subscriptions needed to be monitored by the Elastic + monitor resource. + :vartype properties: ~azure.mgmt.elastic.models.SubscriptionList + """ + + _validation = { + "name": {"readonly": True}, + "id": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "SubscriptionList"}, + } + + def __init__(self, *, properties: Optional["_models.SubscriptionList"] = None, **kwargs: Any) -> None: + """ + :keyword properties: The request to update subscriptions needed to be monitored by the Elastic + monitor resource. + :paramtype properties: ~azure.mgmt.elastic.models.SubscriptionList + """ + super().__init__(**kwargs) + self.name = None + self.id = None + self.type = None + self.properties = properties + + +class MonitoredSubscriptionPropertiesList(_serialization.Model): + """MonitoredSubscriptionPropertiesList. + + :ivar value: + :vartype value: list[~azure.mgmt.elastic.models.MonitoredSubscriptionProperties] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[MonitoredSubscriptionProperties]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.MonitoredSubscriptionProperties"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: + :paramtype value: list[~azure.mgmt.elastic.models.MonitoredSubscriptionProperties] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + class MonitoringTagRules(_serialization.Model): """Capture logs and metrics of Azure resources based on ARM tags. @@ -1082,6 +1562,8 @@ def __init__( class MonitoringTagRulesProperties(_serialization.Model): """Definition of the properties for a TagRules resource. + Variables are only populated by the server, and will be ignored when sending a request. + :ivar provisioning_state: Provisioning state of the monitoring tag rules. Known values are: "Accepted", "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", and "NotSpecified". @@ -1090,32 +1572,26 @@ class MonitoringTagRulesProperties(_serialization.Model): :vartype log_rules: ~azure.mgmt.elastic.models.LogRules """ + _validation = { + "provisioning_state": {"readonly": True}, + } + _attribute_map = { "provisioning_state": {"key": "provisioningState", "type": "str"}, "log_rules": {"key": "logRules", "type": "LogRules"}, } - def __init__( - self, - *, - provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, - log_rules: Optional["_models.LogRules"] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, log_rules: Optional["_models.LogRules"] = None, **kwargs: Any) -> None: """ - :keyword provisioning_state: Provisioning state of the monitoring tag rules. Known values are: - "Accepted", "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", - and "NotSpecified". - :paramtype provisioning_state: str or ~azure.mgmt.elastic.models.ProvisioningState :keyword log_rules: Rules for sending logs. :paramtype log_rules: ~azure.mgmt.elastic.models.LogRules """ super().__init__(**kwargs) - self.provisioning_state = provisioning_state + self.provisioning_state = None self.log_rules = log_rules -class MonitorProperties(_serialization.Model): +class MonitorProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """Properties specific to the monitor resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1131,8 +1607,19 @@ class MonitorProperties(_serialization.Model): :vartype elastic_properties: ~azure.mgmt.elastic.models.ElasticProperties :ivar user_info: User information. :vartype user_info: ~azure.mgmt.elastic.models.UserInfo + :ivar plan_details: Plan details of the monitor resource. + :vartype plan_details: ~azure.mgmt.elastic.models.PlanDetails :ivar version: Version of elastic of the monitor resource. :vartype version: str + :ivar subscription_state: State of the Azure Subscription containing the monitor resource. + :vartype subscription_state: str + :ivar saa_s_azure_subscription_status: Status of Azure Subscription where Marketplace SaaS is + located. + :vartype saa_s_azure_subscription_status: str + :ivar source_campaign_name: Name of the marketing campaign. + :vartype source_campaign_name: str + :ivar source_campaign_id: A unique identifier associated with the campaign. + :vartype source_campaign_id: str :ivar liftr_resource_category: Known values are: "Unknown" and "MonitorLogs". :vartype liftr_resource_category: str or ~azure.mgmt.elastic.models.LiftrResourceCategories :ivar liftr_resource_preference: The priority of the resource. @@ -1142,6 +1629,7 @@ class MonitorProperties(_serialization.Model): """ _validation = { + "provisioning_state": {"readonly": True}, "liftr_resource_category": {"readonly": True}, "liftr_resource_preference": {"readonly": True}, } @@ -1151,7 +1639,12 @@ class MonitorProperties(_serialization.Model): "monitoring_status": {"key": "monitoringStatus", "type": "str"}, "elastic_properties": {"key": "elasticProperties", "type": "ElasticProperties"}, "user_info": {"key": "userInfo", "type": "UserInfo"}, + "plan_details": {"key": "planDetails", "type": "PlanDetails"}, "version": {"key": "version", "type": "str"}, + "subscription_state": {"key": "subscriptionState", "type": "str"}, + "saa_s_azure_subscription_status": {"key": "saaSAzureSubscriptionStatus", "type": "str"}, + "source_campaign_name": {"key": "sourceCampaignName", "type": "str"}, + "source_campaign_id": {"key": "sourceCampaignId", "type": "str"}, "liftr_resource_category": {"key": "liftrResourceCategory", "type": "str"}, "liftr_resource_preference": {"key": "liftrResourcePreference", "type": "int"}, "generate_api_key": {"key": "generateApiKey", "type": "bool"}, @@ -1160,19 +1653,19 @@ class MonitorProperties(_serialization.Model): def __init__( self, *, - provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, monitoring_status: Optional[Union[str, "_models.MonitoringStatus"]] = None, elastic_properties: Optional["_models.ElasticProperties"] = None, user_info: Optional["_models.UserInfo"] = None, + plan_details: Optional["_models.PlanDetails"] = None, version: Optional[str] = None, + subscription_state: Optional[str] = None, + saa_s_azure_subscription_status: Optional[str] = None, + source_campaign_name: Optional[str] = None, + source_campaign_id: Optional[str] = None, generate_api_key: Optional[bool] = None, **kwargs: Any ) -> None: """ - :keyword provisioning_state: Provisioning state of the monitor resource. Known values are: - "Accepted", "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", - and "NotSpecified". - :paramtype provisioning_state: str or ~azure.mgmt.elastic.models.ProvisioningState :keyword monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. Known values are: "Enabled" and "Disabled". :paramtype monitoring_status: str or ~azure.mgmt.elastic.models.MonitoringStatus @@ -1180,22 +1673,208 @@ def __init__( :paramtype elastic_properties: ~azure.mgmt.elastic.models.ElasticProperties :keyword user_info: User information. :paramtype user_info: ~azure.mgmt.elastic.models.UserInfo + :keyword plan_details: Plan details of the monitor resource. + :paramtype plan_details: ~azure.mgmt.elastic.models.PlanDetails :keyword version: Version of elastic of the monitor resource. :paramtype version: str + :keyword subscription_state: State of the Azure Subscription containing the monitor resource. + :paramtype subscription_state: str + :keyword saa_s_azure_subscription_status: Status of Azure Subscription where Marketplace SaaS + is located. + :paramtype saa_s_azure_subscription_status: str + :keyword source_campaign_name: Name of the marketing campaign. + :paramtype source_campaign_name: str + :keyword source_campaign_id: A unique identifier associated with the campaign. + :paramtype source_campaign_id: str :keyword generate_api_key: Flag to determine if User API Key has to be generated and shared. :paramtype generate_api_key: bool """ super().__init__(**kwargs) - self.provisioning_state = provisioning_state + self.provisioning_state = None self.monitoring_status = monitoring_status self.elastic_properties = elastic_properties self.user_info = user_info + self.plan_details = plan_details self.version = version + self.subscription_state = subscription_state + self.saa_s_azure_subscription_status = saa_s_azure_subscription_status + self.source_campaign_name = source_campaign_name + self.source_campaign_id = source_campaign_id self.liftr_resource_category = None self.liftr_resource_preference = None self.generate_api_key = generate_api_key +class OpenAIIntegrationProperties(_serialization.Model): + """Open AI Integration details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar open_ai_resource_id: The resource name of Open AI resource. + :vartype open_ai_resource_id: str + :ivar open_ai_resource_endpoint: The API endpoint for Open AI resource. + :vartype open_ai_resource_endpoint: str + :ivar open_ai_connector_id: The connector id of Open AI resource. + :vartype open_ai_connector_id: str + :ivar key: Value of API key for Open AI resource. + :vartype key: str + :ivar last_refresh_at: Last Update Timestamp for key updation. + :vartype last_refresh_at: ~datetime.datetime + """ + + _validation = { + "last_refresh_at": {"readonly": True}, + } + + _attribute_map = { + "open_ai_resource_id": {"key": "openAIResourceId", "type": "str"}, + "open_ai_resource_endpoint": {"key": "openAIResourceEndpoint", "type": "str"}, + "open_ai_connector_id": {"key": "openAIConnectorId", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "last_refresh_at": {"key": "lastRefreshAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + open_ai_resource_id: Optional[str] = None, + open_ai_resource_endpoint: Optional[str] = None, + open_ai_connector_id: Optional[str] = None, + key: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword open_ai_resource_id: The resource name of Open AI resource. + :paramtype open_ai_resource_id: str + :keyword open_ai_resource_endpoint: The API endpoint for Open AI resource. + :paramtype open_ai_resource_endpoint: str + :keyword open_ai_connector_id: The connector id of Open AI resource. + :paramtype open_ai_connector_id: str + :keyword key: Value of API key for Open AI resource. + :paramtype key: str + """ + super().__init__(**kwargs) + self.open_ai_resource_id = open_ai_resource_id + self.open_ai_resource_endpoint = open_ai_resource_endpoint + self.open_ai_connector_id = open_ai_connector_id + self.key = key + self.last_refresh_at = None + + +class OpenAIIntegrationRPModel(_serialization.Model): + """Capture properties of Open AI resource Integration. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the integration. + :vartype name: str + :ivar id: The id of the integration. + :vartype id: str + :ivar type: The type of the integration. + :vartype type: str + :ivar properties: Open AI Integration details. + :vartype properties: ~azure.mgmt.elastic.models.OpenAIIntegrationProperties + """ + + _validation = { + "name": {"readonly": True}, + "id": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "OpenAIIntegrationProperties"}, + } + + def __init__(self, *, properties: Optional["_models.OpenAIIntegrationProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: Open AI Integration details. + :paramtype properties: ~azure.mgmt.elastic.models.OpenAIIntegrationProperties + """ + super().__init__(**kwargs) + self.name = None + self.id = None + self.type = None + self.properties = properties + + +class OpenAIIntegrationRPModelListResponse(_serialization.Model): + """Response of a list operation. + + :ivar value: Results of a list operation. + :vartype value: list[~azure.mgmt.elastic.models.OpenAIIntegrationRPModel] + :ivar next_link: Link to the next set of results, if any. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[OpenAIIntegrationRPModel]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.OpenAIIntegrationRPModel"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Results of a list operation. + :paramtype value: list[~azure.mgmt.elastic.models.OpenAIIntegrationRPModel] + :keyword next_link: Link to the next set of results, if any. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class OpenAIIntegrationStatusResponse(_serialization.Model): + """Status of the OpenAI Integration. + + :ivar properties: Status of the OpenAI Integration. + :vartype properties: ~azure.mgmt.elastic.models.OpenAIIntegrationStatusResponseProperties + """ + + _attribute_map = { + "properties": {"key": "properties", "type": "OpenAIIntegrationStatusResponseProperties"}, + } + + def __init__( + self, *, properties: Optional["_models.OpenAIIntegrationStatusResponseProperties"] = None, **kwargs: Any + ) -> None: + """ + :keyword properties: Status of the OpenAI Integration. + :paramtype properties: ~azure.mgmt.elastic.models.OpenAIIntegrationStatusResponseProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class OpenAIIntegrationStatusResponseProperties(_serialization.Model): # pylint: disable=name-too-long + """Status of the OpenAI Integration. + + :ivar status: Status of the OpenAI Integration. + :vartype status: str + """ + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, *, status: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword status: Status of the OpenAI Integration. + :paramtype status: str + """ + super().__init__(**kwargs) + self.status = status + + class OperationDisplay(_serialization.Model): """The object that represents the operation. @@ -1316,6 +1995,98 @@ def __init__( self.origin = origin +class PartnerBillingEntity(_serialization.Model): + """Partner Billing details associated with the resource. + + :ivar id: The Elastic Organization Id. + :vartype id: str + :ivar name: The Elastic Organization Name. + :vartype name: str + :ivar partner_entity_uri: Link to the elastic organization page. + :vartype partner_entity_uri: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "partner_entity_uri": {"key": "partnerEntityUri", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + partner_entity_uri: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The Elastic Organization Id. + :paramtype id: str + :keyword name: The Elastic Organization Name. + :paramtype name: str + :keyword partner_entity_uri: Link to the elastic organization page. + :paramtype partner_entity_uri: str + """ + super().__init__(**kwargs) + self.id = id + self.name = name + self.partner_entity_uri = partner_entity_uri + + +class PlanDetails(_serialization.Model): + """Plan details of the monitor resource. + + :ivar offer_id: Offer ID of the plan. + :vartype offer_id: str + :ivar publisher_id: Publisher ID of the plan. + :vartype publisher_id: str + :ivar term_id: Term ID of the plan. + :vartype term_id: str + :ivar plan_id: Plan ID. + :vartype plan_id: str + :ivar plan_name: Plan Name. + :vartype plan_name: str + """ + + _attribute_map = { + "offer_id": {"key": "offerID", "type": "str"}, + "publisher_id": {"key": "publisherID", "type": "str"}, + "term_id": {"key": "termID", "type": "str"}, + "plan_id": {"key": "planID", "type": "str"}, + "plan_name": {"key": "planName", "type": "str"}, + } + + def __init__( + self, + *, + offer_id: Optional[str] = None, + publisher_id: Optional[str] = None, + term_id: Optional[str] = None, + plan_id: Optional[str] = None, + plan_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword offer_id: Offer ID of the plan. + :paramtype offer_id: str + :keyword publisher_id: Publisher ID of the plan. + :paramtype publisher_id: str + :keyword term_id: Term ID of the plan. + :paramtype term_id: str + :keyword plan_id: Plan ID. + :paramtype plan_id: str + :keyword plan_name: Plan Name. + :paramtype plan_name: str + """ + super().__init__(**kwargs) + self.offer_id = offer_id + self.publisher_id = publisher_id + self.term_id = term_id + self.plan_id = plan_id + self.plan_name = plan_name + + class ResourceProviderDefaultErrorResponse(_serialization.Model): """RP default error response. @@ -1342,7 +2113,7 @@ def __init__(self, **kwargs: Any) -> None: class ResourceSku(_serialization.Model): """Microsoft.Elastic SKU. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: Name of the SKU. Required. :vartype name: str @@ -1365,6 +2136,113 @@ def __init__(self, *, name: str, **kwargs: Any) -> None: self.name = name +class ResubscribeProperties(_serialization.Model): + """Resubscribe Properties. + + :ivar plan_id: Newly selected plan Id to create the new Marketplace subscription for + Resubscribe. + :vartype plan_id: str + :ivar term: Newly selected term to create the new Marketplace subscription for Resubscribe. + :vartype term: str + :ivar subscription_id: Newly selected Azure Subscription Id in which the new Marketplace + subscription will be created for Resubscribe. + :vartype subscription_id: str + :ivar resource_group: Newly selected Azure resource group in which the new Marketplace + subscription will be created for Resubscribe. + :vartype resource_group: str + :ivar organization_id: Organization Id of the Elastic Organization that needs to be + resubscribed. + :vartype organization_id: str + """ + + _attribute_map = { + "plan_id": {"key": "planId", "type": "str"}, + "term": {"key": "term", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + "organization_id": {"key": "organizationId", "type": "str"}, + } + + def __init__( + self, + *, + plan_id: Optional[str] = None, + term: Optional[str] = None, + subscription_id: Optional[str] = None, + resource_group: Optional[str] = None, + organization_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword plan_id: Newly selected plan Id to create the new Marketplace subscription for + Resubscribe. + :paramtype plan_id: str + :keyword term: Newly selected term to create the new Marketplace subscription for Resubscribe. + :paramtype term: str + :keyword subscription_id: Newly selected Azure Subscription Id in which the new Marketplace + subscription will be created for Resubscribe. + :paramtype subscription_id: str + :keyword resource_group: Newly selected Azure resource group in which the new Marketplace + subscription will be created for Resubscribe. + :paramtype resource_group: str + :keyword organization_id: Organization Id of the Elastic Organization that needs to be + resubscribed. + :paramtype organization_id: str + """ + super().__init__(**kwargs) + self.plan_id = plan_id + self.term = term + self.subscription_id = subscription_id + self.resource_group = resource_group + self.organization_id = organization_id + + +class SubscriptionList(_serialization.Model): + """The request to update subscriptions needed to be monitored by the Elastic monitor resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar operation: The operation for the patch on the resource. Known values are: "AddBegin", + "AddComplete", "DeleteBegin", "DeleteComplete", and "Active". + :vartype operation: str or ~azure.mgmt.elastic.models.Operation + :ivar monitored_subscription_list: List of subscriptions and the state of the monitoring. + :vartype monitored_subscription_list: list[~azure.mgmt.elastic.models.MonitoredSubscription] + :ivar provisioning_state: Provisioning State of the resource. Known values are: "Accepted", + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", and + "NotSpecified". + :vartype provisioning_state: str or ~azure.mgmt.elastic.models.ProvisioningState + """ + + _validation = { + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "operation": {"key": "operation", "type": "str"}, + "monitored_subscription_list": {"key": "monitoredSubscriptionList", "type": "[MonitoredSubscription]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + operation: Optional[Union[str, "_models.Operation"]] = None, + monitored_subscription_list: Optional[List["_models.MonitoredSubscription"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword operation: The operation for the patch on the resource. Known values are: "AddBegin", + "AddComplete", "DeleteBegin", "DeleteComplete", and "Active". + :paramtype operation: str or ~azure.mgmt.elastic.models.Operation + :keyword monitored_subscription_list: List of subscriptions and the state of the monitoring. + :paramtype monitored_subscription_list: list[~azure.mgmt.elastic.models.MonitoredSubscription] + """ + super().__init__(**kwargs) + self.operation = operation + self.monitored_subscription_list = monitored_subscription_list + self.provisioning_state = None + + class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. @@ -1536,9 +2414,9 @@ class UserInfo(_serialization.Model): """ _validation = { - "first_name": {"max_length": 50}, - "last_name": {"max_length": 50}, - "company_name": {"max_length": 64}, + "first_name": {"max_length": 128}, + "last_name": {"max_length": 128}, + "company_name": {"max_length": 128}, "email_address": { "pattern": r'^([^<>()\[\]\.,;:\s@"]+(\.[^<>()\[\]\.,;:\s@"]+)*)@(([a-zA-Z-_0-9]+\.)+[a-zA-Z]{2,})$' }, diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/__init__.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/__init__.py index e04a06140193..1cdfeb9a7b42 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/__init__.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/__init__.py @@ -9,9 +9,13 @@ from ._operations import Operations from ._monitors_operations import MonitorsOperations from ._elastic_versions_operations import ElasticVersionsOperations +from ._monitored_subscriptions_operations import MonitoredSubscriptionsOperations from ._monitored_resources_operations import MonitoredResourcesOperations from ._deployment_info_operations import DeploymentInfoOperations from ._external_user_operations import ExternalUserOperations +from ._billing_info_operations import BillingInfoOperations +from ._connected_partner_resources_operations import ConnectedPartnerResourcesOperations +from ._open_ai_operations import OpenAIOperations from ._tag_rules_operations import TagRulesOperations from ._vm_host_operations import VMHostOperations from ._vm_ingestion_operations import VMIngestionOperations @@ -36,9 +40,13 @@ "Operations", "MonitorsOperations", "ElasticVersionsOperations", + "MonitoredSubscriptionsOperations", "MonitoredResourcesOperations", "DeploymentInfoOperations", "ExternalUserOperations", + "BillingInfoOperations", + "ConnectedPartnerResourcesOperations", + "OpenAIOperations", "TagRulesOperations", "VMHostOperations", "VMIngestionOperations", diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_all_traffic_filters_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_all_traffic_filters_operations.py index 44f6f3f4ef83..def1ee3a0262 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_all_traffic_filters_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_all_traffic_filters_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +41,7 @@ def build_list_request(resource_group_name: str, monitor_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -48,11 +51,13 @@ def build_list_request(resource_group_name: str, monitor_name: str, subscription ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -88,17 +93,16 @@ def list(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> _m Get the list of all traffic filters for the account. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ElasticTrafficFilterResponse or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.ElasticTrafficFilterResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,21 +116,19 @@ def list(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticTrafficFilterResponse] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, monitor_name=monitor_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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -138,13 +140,9 @@ def list(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> _m ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ElasticTrafficFilterResponse", pipeline_response) + deserialized = self._deserialize("ElasticTrafficFilterResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/listAllTrafficFilters" - } + return deserialized # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_associate_traffic_filter_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_associate_traffic_filter_operations.py index f4d6ca047c10..44408a2aa7cc 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_associate_traffic_filter_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_associate_traffic_filter_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, Callable, Dict, Iterator, Optional, Type, TypeVar, Union, cast from azure.core.exceptions import ( ClientAuthenticationError, @@ -14,12 +15,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -27,8 +29,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +52,7 @@ def build_associate_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -57,11 +62,13 @@ def build_associate_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,10 +100,10 @@ def __init__(self, *args, **kwargs): self._serialize = 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 _associate_initial( # pylint: disable=inconsistent-return-statements + def _associate_initial( self, resource_group_name: str, monitor_name: str, ruleset_id: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -108,41 +115,44 @@ def _associate_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_associate_request( + _request = build_associate_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, ruleset_id=ruleset_id, api_version=api_version, - template_url=self._associate_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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( _models.ResourceProviderDefaultErrorResponse, pipeline_response ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _associate_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/associateTrafficFilter" - } + return deserialized # type: ignore @distributed_trace def begin_associate( @@ -152,21 +162,13 @@ def begin_associate( Associate traffic filter for the given deployment. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param ruleset_id: Ruleset Id of the filter. Default value is None. :type ruleset_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -180,7 +182,7 @@ def begin_associate( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._associate_initial( # type: ignore + raw_result = self._associate_initial( resource_group_name=resource_group_name, monitor_name=monitor_name, ruleset_id=ruleset_id, @@ -190,11 +192,12 @@ def begin_associate( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -205,14 +208,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_associate.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/associateTrafficFilter" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_billing_info_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_billing_info_operations.py new file mode 100644 index 000000000000..85b79f588450 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_billing_info_operations.py @@ -0,0 +1,148 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(resource_group_name: str, monitor_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/getBillingInfo", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class BillingInfoOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elastic.MicrosoftElastic`'s + :attr:`billing_info` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> _models.BillingInfoResponse: + """Get marketplace and organization info mapped to the given monitor. + + Get marketplace and organization info mapped to the given monitor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :return: BillingInfoResponse or the result of cls(response) + :rtype: ~azure.mgmt.elastic.models.BillingInfoResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.BillingInfoResponse] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ResourceProviderDefaultErrorResponse, pipeline_response + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BillingInfoResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_connected_partner_resources_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_connected_partner_resources_operations.py new file mode 100644 index 000000000000..db37b609ed6c --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_connected_partner_resources_operations.py @@ -0,0 +1,182 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(resource_group_name: str, monitor_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/listConnectedPartnerResources", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class ConnectedPartnerResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elastic.MicrosoftElastic`'s + :attr:`connected_partner_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, monitor_name: str, **kwargs: Any + ) -> Iterable["_models.ConnectedPartnerResourcesListFormat"]: + """List of all active deployments that are associated with the marketplace subscription linked to + the given monitor. + + List of all active deployments that are associated with the marketplace subscription linked to + the given monitor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :return: An iterator like instance of either ConnectedPartnerResourcesListFormat or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.elastic.models.ConnectedPartnerResourcesListFormat] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ConnectedPartnerResourcesListResponse] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ConnectedPartnerResourcesListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ResourceProviderDefaultErrorResponse, pipeline_response + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_create_and_associate_ip_filter_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_create_and_associate_ip_filter_operations.py index 2e77e0738887..afb30954e2b2 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_create_and_associate_ip_filter_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_create_and_associate_ip_filter_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, Callable, Dict, Iterator, Optional, Type, TypeVar, Union, cast from azure.core.exceptions import ( ClientAuthenticationError, @@ -14,12 +15,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -27,8 +29,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -48,7 +53,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -58,11 +63,13 @@ def build_create_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -96,15 +103,15 @@ def __init__(self, *args, **kwargs): self._serialize = 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_initial( # pylint: disable=inconsistent-return-statements + def _create_initial( self, resource_group_name: str, monitor_name: str, ips: Optional[str] = None, name: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -116,42 +123,45 @@ def _create_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, ips=ips, name=name, api_version=api_version, - template_url=self._create_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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( _models.ResourceProviderDefaultErrorResponse, pipeline_response ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/createAndAssociateIPFilter" - } + return deserialized # type: ignore @distributed_trace def begin_create( @@ -166,8 +176,8 @@ def begin_create( Create and Associate IP traffic filter for the given deployment. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str @@ -175,14 +185,6 @@ def begin_create( :type ips: str :param name: Name of the traffic filter. Default value is None. :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -196,7 +198,7 @@ def begin_create( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_initial( # type: ignore + raw_result = self._create_initial( resource_group_name=resource_group_name, monitor_name=monitor_name, ips=ips, @@ -207,11 +209,12 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -222,14 +225,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/createAndAssociateIPFilter" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_create_and_associate_pl_filter_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_create_and_associate_pl_filter_operations.py index 61010dd5b257..c0b4948c781b 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_create_and_associate_pl_filter_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_create_and_associate_pl_filter_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, Callable, Dict, Iterator, Optional, Type, TypeVar, Union, cast from azure.core.exceptions import ( ClientAuthenticationError, @@ -14,12 +15,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -27,8 +29,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +54,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,11 +64,13 @@ def build_create_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -99,7 +106,7 @@ def __init__(self, *args, **kwargs): self._serialize = 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_initial( # pylint: disable=inconsistent-return-statements + def _create_initial( self, resource_group_name: str, monitor_name: str, @@ -107,8 +114,8 @@ def _create_initial( # pylint: disable=inconsistent-return-statements private_endpoint_guid: Optional[str] = None, private_endpoint_name: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -120,9 +127,9 @@ def _create_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, @@ -130,33 +137,36 @@ def _create_initial( # pylint: disable=inconsistent-return-statements private_endpoint_guid=private_endpoint_guid, private_endpoint_name=private_endpoint_name, api_version=api_version, - template_url=self._create_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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( _models.ResourceProviderDefaultErrorResponse, pipeline_response ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/createAndAssociatePLFilter" - } + return deserialized # type: ignore @distributed_trace def begin_create( @@ -172,8 +182,8 @@ def begin_create( Create and Associate private link traffic filter for the given deployment. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str @@ -183,14 +193,6 @@ def begin_create( :type private_endpoint_guid: str :param private_endpoint_name: Name of the private endpoint. Default value is None. :type private_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -204,7 +206,7 @@ def begin_create( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_initial( # type: ignore + raw_result = self._create_initial( resource_group_name=resource_group_name, monitor_name=monitor_name, name=name, @@ -216,11 +218,12 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -231,14 +234,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/createAndAssociatePLFilter" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_deployment_info_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_deployment_info_operations.py index c550079dba14..9bf88e5b45d7 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_deployment_info_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_deployment_info_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +41,7 @@ def build_list_request(resource_group_name: str, monitor_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -48,11 +51,13 @@ def build_list_request(resource_group_name: str, monitor_name: str, subscription ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -90,17 +95,16 @@ def list(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> _m Fetch information regarding Elastic cloud deployment corresponding to the Elastic monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeploymentInfoResponse or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.DeploymentInfoResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -114,21 +118,19 @@ def list(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DeploymentInfoResponse] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, monitor_name=monitor_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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -140,13 +142,9 @@ def list(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> _m ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DeploymentInfoResponse", pipeline_response) + deserialized = self._deserialize("DeploymentInfoResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/listDeploymentInfo" - } + return deserialized # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_detach_and_delete_traffic_filter_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_detach_and_delete_traffic_filter_operations.py index 141ac6d0a687..1f70b52b99c3 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_detach_and_delete_traffic_filter_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_detach_and_delete_traffic_filter_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +48,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -55,11 +58,13 @@ def build_delete_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -99,19 +104,18 @@ def delete( # pylint: disable=inconsistent-return-statements Detach and Delete traffic filter from the given deployment. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param ruleset_id: Ruleset Id of the filter. Default value is None. :type ruleset_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -125,22 +129,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, ruleset_id=ruleset_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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -153,8 +155,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/detachAndDeleteTrafficFilter" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_detach_traffic_filter_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_detach_traffic_filter_operations.py index 4bbac697a4cb..29a5820e1293 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_detach_traffic_filter_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_detach_traffic_filter_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, Callable, Dict, Iterator, Optional, Type, TypeVar, Union, cast from azure.core.exceptions import ( ClientAuthenticationError, @@ -14,12 +15,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -27,8 +29,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +52,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -57,11 +62,13 @@ def build_update_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,10 +100,10 @@ def __init__(self, *args, **kwargs): self._serialize = 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 _update_initial( # pylint: disable=inconsistent-return-statements + def _update_initial( self, resource_group_name: str, monitor_name: str, ruleset_id: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -108,41 +115,44 @@ def _update_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, ruleset_id=ruleset_id, api_version=api_version, - 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( _models.ResourceProviderDefaultErrorResponse, pipeline_response ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/detachTrafficFilter" - } + return deserialized # type: ignore @distributed_trace def begin_update( @@ -152,21 +162,13 @@ def begin_update( Detach traffic filter for the given deployment. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param ruleset_id: Ruleset Id of the filter. Default value is None. :type ruleset_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -180,7 +182,7 @@ def begin_update( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._update_initial( # type: ignore + raw_result = self._update_initial( resource_group_name=resource_group_name, monitor_name=monitor_name, ruleset_id=ruleset_id, @@ -190,11 +192,12 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -205,14 +208,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/detachTrafficFilter" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_elastic_versions_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_elastic_versions_operations.py index a64062bb7e85..4b04dd23024f 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_elastic_versions_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_elastic_versions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ def build_list_request(subscription_id: str, *, region: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -49,7 +52,7 @@ def build_list_request(subscription_id: str, *, region: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -88,7 +91,6 @@ def list(self, region: str, **kwargs: Any) -> Iterable["_models.ElasticVersionLi :param region: Region where elastic deployment will take place. Required. :type region: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ElasticVersionListFormat or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elastic.models.ElasticVersionListFormat] @@ -100,7 +102,7 @@ def list(self, region: str, **kwargs: Any) -> Iterable["_models.ElasticVersionLi api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticVersionsListResponse] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -111,16 +113,14 @@ def list(self, region: str, **kwargs: Any) -> Iterable["_models.ElasticVersionLi def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, region=region, 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) else: # make call to next link with the client's api-version @@ -132,13 +132,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ElasticVersionsListResponse", pipeline_response) @@ -148,11 +147,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -166,5 +165,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Elastic/elasticVersions"} diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_external_user_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_external_user_operations.py index 13aaee3c5836..90f00516fff7 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_external_user_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_external_user_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +44,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -51,11 +55,13 @@ def build_create_or_update_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -103,8 +109,8 @@ def create_or_update( Create User inside elastic deployment which are used by customers to perform operations on the elastic deployment. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str @@ -113,7 +119,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ExternalUserCreationResponse or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.ExternalUserCreationResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -124,7 +129,7 @@ def create_or_update( self, resource_group_name: str, monitor_name: str, - body: Optional[IO] = None, + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -135,17 +140,16 @@ def create_or_update( Create User inside elastic deployment which are used by customers to perform operations on the elastic deployment. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param body: Elastic External User Creation Parameters. Default value is None. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ExternalUserCreationResponse or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.ExternalUserCreationResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -156,7 +160,7 @@ def create_or_update( self, resource_group_name: str, monitor_name: str, - body: Optional[Union[_models.ExternalUserInfo, IO]] = None, + body: Optional[Union[_models.ExternalUserInfo, IO[bytes]]] = None, **kwargs: Any ) -> _models.ExternalUserCreationResponse: """Create User inside elastic deployment which are used by customers to perform operations on the @@ -165,23 +169,19 @@ def create_or_update( Create User inside elastic deployment which are used by customers to perform operations on the elastic deployment. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param body: Elastic External User Creation Parameters. Is either a ExternalUserInfo type or a - IO type. Default value is None. - :type body: ~azure.mgmt.elastic.models.ExternalUserInfo or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.elastic.models.ExternalUserInfo or IO[bytes] :return: ExternalUserCreationResponse or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.ExternalUserCreationResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -199,7 +199,7 @@ def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: if body is not None: @@ -207,7 +207,7 @@ def create_or_update( else: _json = None - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, @@ -215,16 +215,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -236,13 +234,9 @@ def create_or_update( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ExternalUserCreationResponse", pipeline_response) + deserialized = self._deserialize("ExternalUserCreationResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/createOrUpdateExternalUser" - } + return deserialized # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_list_associated_traffic_filters_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_list_associated_traffic_filters_operations.py index 8455ed2d8eea..655798c799fe 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_list_associated_traffic_filters_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_list_associated_traffic_filters_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +41,7 @@ def build_list_request(resource_group_name: str, monitor_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -48,11 +51,13 @@ def build_list_request(resource_group_name: str, monitor_name: str, subscription ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -88,17 +93,16 @@ def list(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> _m Get the list of all associated traffic filters for the given deployment. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ElasticTrafficFilterResponse or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.ElasticTrafficFilterResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,21 +116,19 @@ def list(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticTrafficFilterResponse] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, monitor_name=monitor_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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -138,13 +140,9 @@ def list(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> _m ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ElasticTrafficFilterResponse", pipeline_response) + deserialized = self._deserialize("ElasticTrafficFilterResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/listAssociatedTrafficFilters" - } + return deserialized # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_monitor_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_monitor_operations.py index c53c7ded4ea8..b025a50d1af1 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_monitor_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_monitor_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterator, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -14,12 +16,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -27,8 +30,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +48,7 @@ def build_upgrade_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -53,11 +59,13 @@ def build_upgrade_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -89,14 +97,14 @@ def __init__(self, *args, **kwargs): self._serialize = 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 _upgrade_initial( # pylint: disable=inconsistent-return-statements + def _upgrade_initial( self, resource_group_name: str, monitor_name: str, - body: Optional[Union[_models.ElasticMonitorUpgrade, IO]] = None, + body: Optional[Union[_models.ElasticMonitorUpgrade, IO[bytes]]] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -109,12 +117,12 @@ def _upgrade_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: if body is not None: @@ -122,7 +130,7 @@ def _upgrade_initial( # pylint: disable=inconsistent-return-statements else: _json = None - request = build_upgrade_request( + _request = build_upgrade_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, @@ -130,33 +138,36 @@ def _upgrade_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self._upgrade_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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( _models.ResourceProviderDefaultErrorResponse, pipeline_response ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _upgrade_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/upgrade" - } + return deserialized # type: ignore @overload def begin_upgrade( @@ -172,8 +183,8 @@ def begin_upgrade( Upgradable version for a monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str @@ -182,14 +193,6 @@ def begin_upgrade( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -200,7 +203,7 @@ def begin_upgrade( self, resource_group_name: str, monitor_name: str, - body: Optional[IO] = None, + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -209,24 +212,16 @@ def begin_upgrade( Upgradable version for a monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param body: Elastic Monitor Upgrade Parameters. Default value is None. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -237,32 +232,21 @@ def begin_upgrade( self, resource_group_name: str, monitor_name: str, - body: Optional[Union[_models.ElasticMonitorUpgrade, IO]] = None, + body: Optional[Union[_models.ElasticMonitorUpgrade, IO[bytes]]] = None, **kwargs: Any ) -> LROPoller[None]: """Upgradable version for a monitor resource. Upgradable version for a monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :param body: Elastic Monitor Upgrade Parameters. Is either a ElasticMonitorUpgrade type or a IO - type. Default value is None. - :type body: ~azure.mgmt.elastic.models.ElasticMonitorUpgrade or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param body: Elastic Monitor Upgrade Parameters. Is either a ElasticMonitorUpgrade type or a + IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.elastic.models.ElasticMonitorUpgrade or IO[bytes] :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -277,7 +261,7 @@ def begin_upgrade( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._upgrade_initial( # type: ignore + raw_result = self._upgrade_initial( resource_group_name=resource_group_name, monitor_name=monitor_name, body=body, @@ -288,11 +272,12 @@ def begin_upgrade( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -301,14 +286,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_upgrade.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/upgrade" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_monitored_resources_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_monitored_resources_operations.py index 81896222cd8c..0239412b0a11 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_monitored_resources_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_monitored_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ def build_list_request(resource_group_name: str, monitor_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -50,11 +53,13 @@ def build_list_request(resource_group_name: str, monitor_name: str, subscription ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -90,12 +95,11 @@ def list(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> It List the resources currently being monitored by the Elastic monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MonitoredResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elastic.models.MonitoredResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -106,7 +110,7 @@ def list(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MonitoredResourceListResponse] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -117,17 +121,15 @@ def list(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, monitor_name=monitor_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) else: # make call to next link with the client's api-version @@ -139,13 +141,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("MonitoredResourceListResponse", pipeline_response) @@ -155,11 +156,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -173,7 +174,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/listMonitoredResources" - } diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_monitored_subscriptions_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_monitored_subscriptions_operations.py new file mode 100644 index 000000000000..3c57232e6e09 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_monitored_subscriptions_operations.py @@ -0,0 +1,942 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(resource_group_name: str, monitor_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/monitoredSubscriptions", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, monitor_name: str, configuration_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/monitoredSubscriptions/{configurationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str", pattern=r"^.*$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_createor_update_request( + resource_group_name: str, monitor_name: str, configuration_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/monitoredSubscriptions/{configurationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str", pattern=r"^.*$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, monitor_name: str, configuration_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/monitoredSubscriptions/{configurationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str", pattern=r"^.*$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, monitor_name: str, configuration_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/monitoredSubscriptions/{configurationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str", pattern=r"^.*$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class MonitoredSubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elastic.MicrosoftElastic`'s + :attr:`monitored_subscriptions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, monitor_name: str, **kwargs: Any + ) -> Iterable["_models.MonitoredSubscriptionProperties"]: + """List all the subscriptions currently being monitored by the Elastic monitor resource. + + List all the subscriptions currently being monitored by the Elastic monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :return: An iterator like instance of either MonitoredSubscriptionProperties or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.elastic.models.MonitoredSubscriptionProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.MonitoredSubscriptionPropertiesList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("MonitoredSubscriptionPropertiesList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, monitor_name: str, configuration_name: str, **kwargs: Any + ) -> _models.MonitoredSubscriptionProperties: + """List all the subscriptions currently being monitored by the Elastic monitor resource. + + List all the subscriptions currently being monitored by the Elastic monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param configuration_name: The configuration name. Only 'default' value is supported. Required. + :type configuration_name: str + :return: MonitoredSubscriptionProperties or the result of cls(response) + :rtype: ~azure.mgmt.elastic.models.MonitoredSubscriptionProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.MonitoredSubscriptionProperties] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MonitoredSubscriptionProperties", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _createor_update_initial( + self, + resource_group_name: str, + monitor_name: str, + configuration_name: str, + body: Optional[Union[_models.MonitoredSubscriptionProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "MonitoredSubscriptionProperties") + else: + _json = None + + _request = build_createor_update_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_createor_update( + self, + resource_group_name: str, + monitor_name: str, + configuration_name: str, + body: Optional[_models.MonitoredSubscriptionProperties] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoredSubscriptionProperties]: + """Add the subscriptions that should be monitored by the Elastic monitor resource. + + Add the subscriptions that should be monitored by the Elastic monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param configuration_name: The configuration name. Only 'default' value is supported. Required. + :type configuration_name: str + :param body: Default value is None. + :type body: ~azure.mgmt.elastic.models.MonitoredSubscriptionProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either MonitoredSubscriptionProperties or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.elastic.models.MonitoredSubscriptionProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_createor_update( + self, + resource_group_name: str, + monitor_name: str, + configuration_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoredSubscriptionProperties]: + """Add the subscriptions that should be monitored by the Elastic monitor resource. + + Add the subscriptions that should be monitored by the Elastic monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param configuration_name: The configuration name. Only 'default' value is supported. Required. + :type configuration_name: str + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either MonitoredSubscriptionProperties or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.elastic.models.MonitoredSubscriptionProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_createor_update( + self, + resource_group_name: str, + monitor_name: str, + configuration_name: str, + body: Optional[Union[_models.MonitoredSubscriptionProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.MonitoredSubscriptionProperties]: + """Add the subscriptions that should be monitored by the Elastic monitor resource. + + Add the subscriptions that should be monitored by the Elastic monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param configuration_name: The configuration name. Only 'default' value is supported. Required. + :type configuration_name: str + :param body: Is either a MonitoredSubscriptionProperties type or a IO[bytes] type. Default + value is None. + :type body: ~azure.mgmt.elastic.models.MonitoredSubscriptionProperties or IO[bytes] + :return: An instance of LROPoller that returns either MonitoredSubscriptionProperties or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.elastic.models.MonitoredSubscriptionProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MonitoredSubscriptionProperties] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._createor_update_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + configuration_name=configuration_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("MonitoredSubscriptionProperties", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.MonitoredSubscriptionProperties].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.MonitoredSubscriptionProperties]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + monitor_name: str, + configuration_name: str, + body: Optional[Union[_models.MonitoredSubscriptionProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "MonitoredSubscriptionProperties") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + monitor_name: str, + configuration_name: str, + body: Optional[_models.MonitoredSubscriptionProperties] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoredSubscriptionProperties]: + """Updates the subscriptions that are being monitored by the Elastic monitor resource. + + Updates the subscriptions that are being monitored by the Elastic monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param configuration_name: The configuration name. Only 'default' value is supported. Required. + :type configuration_name: str + :param body: Default value is None. + :type body: ~azure.mgmt.elastic.models.MonitoredSubscriptionProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either MonitoredSubscriptionProperties or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.elastic.models.MonitoredSubscriptionProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + monitor_name: str, + configuration_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoredSubscriptionProperties]: + """Updates the subscriptions that are being monitored by the Elastic monitor resource. + + Updates the subscriptions that are being monitored by the Elastic monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param configuration_name: The configuration name. Only 'default' value is supported. Required. + :type configuration_name: str + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either MonitoredSubscriptionProperties or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.elastic.models.MonitoredSubscriptionProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + monitor_name: str, + configuration_name: str, + body: Optional[Union[_models.MonitoredSubscriptionProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.MonitoredSubscriptionProperties]: + """Updates the subscriptions that are being monitored by the Elastic monitor resource. + + Updates the subscriptions that are being monitored by the Elastic monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param configuration_name: The configuration name. Only 'default' value is supported. Required. + :type configuration_name: str + :param body: Is either a MonitoredSubscriptionProperties type or a IO[bytes] type. Default + value is None. + :type body: ~azure.mgmt.elastic.models.MonitoredSubscriptionProperties or IO[bytes] + :return: An instance of LROPoller that returns either MonitoredSubscriptionProperties or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.elastic.models.MonitoredSubscriptionProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MonitoredSubscriptionProperties] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + configuration_name=configuration_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("MonitoredSubscriptionProperties", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.MonitoredSubscriptionProperties].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.MonitoredSubscriptionProperties]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, monitor_name: str, configuration_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, monitor_name: str, configuration_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Updates the subscriptions that are being monitored by the Elastic monitor resource. + + Updates the subscriptions that are being monitored by the Elastic monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param configuration_name: The configuration name. Only 'default' value is supported. Required. + :type configuration_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + configuration_name=configuration_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_monitors_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_monitors_operations.py index 58da5f864dae..d19e5e659d2e 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_monitors_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_monitors_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -15,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -29,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +48,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -51,7 +57,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -66,7 +72,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -76,10 +82,12 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -94,7 +102,7 @@ def build_get_request(resource_group_name: str, monitor_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -104,11 +112,13 @@ def build_get_request(resource_group_name: str, monitor_name: str, subscription_ ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -125,7 +135,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -136,11 +146,13 @@ def build_create_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -159,7 +171,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -170,11 +182,13 @@ def build_update_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -193,7 +207,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -203,11 +217,13 @@ def build_delete_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -243,7 +259,6 @@ def list(self, **kwargs: Any) -> Iterable["_models.ElasticMonitorResource"]: List all monitors under the specified subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ElasticMonitorResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elastic.models.ElasticMonitorResource] @@ -255,7 +270,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.ElasticMonitorResource"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticMonitorResourceListResponse] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -266,15 +281,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.ElasticMonitorResource"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _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) else: # make call to next link with the client's api-version @@ -286,13 +299,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ElasticMonitorResourceListResponse", pipeline_response) @@ -302,11 +314,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -321,8 +333,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Elastic/monitors"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -331,10 +341,9 @@ def list_by_resource_group( List all monitors under the specified resource group. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ElasticMonitorResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elastic.models.ElasticMonitorResource] @@ -346,7 +355,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticMonitorResourceListResponse] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -357,16 +366,14 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _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) else: # make call to next link with the client's api-version @@ -378,13 +385,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ElasticMonitorResourceListResponse", pipeline_response) @@ -394,11 +400,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -413,27 +419,22 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors" - } - @distributed_trace def get(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> _models.ElasticMonitorResource: """Get the properties of a specific monitor resource. Get the properties of a specific monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ElasticMonitorResource or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.ElasticMonitorResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -447,21 +448,19 @@ def get(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> _mo api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticMonitorResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, monitor_name=monitor_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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -473,25 +472,21 @@ def get(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> _mo ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ElasticMonitorResource", pipeline_response) + deserialized = self._deserialize("ElasticMonitorResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, monitor_name: str, - body: Optional[Union[_models.ElasticMonitorResource, IO]] = None, + body: Optional[Union[_models.ElasticMonitorResource, IO[bytes]]] = None, **kwargs: Any - ) -> _models.ElasticMonitorResource: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -504,12 +499,12 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ElasticMonitorResource] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: if body is not None: @@ -517,7 +512,7 @@ def _create_initial( else: _json = None - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, @@ -525,42 +520,37 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( _models.ResourceProviderDefaultErrorResponse, pipeline_response ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ElasticMonitorResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ElasticMonitorResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}" - } - @overload def begin_create( self, @@ -575,8 +565,8 @@ def begin_create( Create a monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str @@ -585,14 +575,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either ElasticMonitorResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elastic.models.ElasticMonitorResource] @@ -604,7 +586,7 @@ def begin_create( self, resource_group_name: str, monitor_name: str, - body: Optional[IO] = None, + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -613,24 +595,16 @@ def begin_create( Create a monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param body: Elastic monitor resource model. Default value is None. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either ElasticMonitorResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elastic.models.ElasticMonitorResource] @@ -642,32 +616,21 @@ def begin_create( self, resource_group_name: str, monitor_name: str, - body: Optional[Union[_models.ElasticMonitorResource, IO]] = None, + body: Optional[Union[_models.ElasticMonitorResource, IO[bytes]]] = None, **kwargs: Any ) -> LROPoller[_models.ElasticMonitorResource]: """Create a monitor resource. Create a monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :param body: Elastic monitor resource model. Is either a ElasticMonitorResource type or a IO - type. Default value is None. - :type body: ~azure.mgmt.elastic.models.ElasticMonitorResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param body: Elastic monitor resource model. Is either a ElasticMonitorResource type or a + IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.elastic.models.ElasticMonitorResource or IO[bytes] :return: An instance of LROPoller that returns either ElasticMonitorResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elastic.models.ElasticMonitorResource] @@ -694,12 +657,13 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ElasticMonitorResource", pipeline_response) + deserialized = self._deserialize("ElasticMonitorResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -711,20 +675,92 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ElasticMonitorResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller[_models.ElasticMonitorResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}" - } + def _update_initial( + self, + resource_group_name: str, + monitor_name: str, + body: Optional[Union[_models.ElasticMonitorResourceUpdateParameters, IO[bytes]]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "ElasticMonitorResourceUpdateParameters") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload - def update( + def begin_update( self, resource_group_name: str, monitor_name: str, @@ -732,13 +768,13 @@ def update( *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ElasticMonitorResource: + ) -> LROPoller[_models.ElasticMonitorResource]: """Update a monitor resource. Update a monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str @@ -747,140 +783,118 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ElasticMonitorResource or the result of cls(response) - :rtype: ~azure.mgmt.elastic.models.ElasticMonitorResource + :return: An instance of LROPoller that returns either ElasticMonitorResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elastic.models.ElasticMonitorResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( + def begin_update( self, resource_group_name: str, monitor_name: str, - body: Optional[IO] = None, + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ElasticMonitorResource: + ) -> LROPoller[_models.ElasticMonitorResource]: """Update a monitor resource. Update a monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param body: Elastic resource model update parameters. Default value is None. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ElasticMonitorResource or the result of cls(response) - :rtype: ~azure.mgmt.elastic.models.ElasticMonitorResource + :return: An instance of LROPoller that returns either ElasticMonitorResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elastic.models.ElasticMonitorResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def update( + def begin_update( self, resource_group_name: str, monitor_name: str, - body: Optional[Union[_models.ElasticMonitorResourceUpdateParameters, IO]] = None, + body: Optional[Union[_models.ElasticMonitorResourceUpdateParameters, IO[bytes]]] = None, **kwargs: Any - ) -> _models.ElasticMonitorResource: + ) -> LROPoller[_models.ElasticMonitorResource]: """Update a monitor resource. Update a monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param body: Elastic resource model update parameters. Is either a - ElasticMonitorResourceUpdateParameters type or a IO type. Default value is None. - :type body: ~azure.mgmt.elastic.models.ElasticMonitorResourceUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ElasticMonitorResource or the result of cls(response) - :rtype: ~azure.mgmt.elastic.models.ElasticMonitorResource + ElasticMonitorResourceUpdateParameters type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.elastic.models.ElasticMonitorResourceUpdateParameters or IO[bytes] + :return: An instance of LROPoller that returns either ElasticMonitorResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elastic.models.ElasticMonitorResource] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ElasticMonitorResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "ElasticMonitorResourceUpdateParameters") - else: - _json = None - - request = build_update_request( - resource_group_name=resource_group_name, - monitor_name=monitor_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ResourceProviderDefaultErrorResponse, pipeline_response + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ElasticMonitorResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - return deserialized + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ElasticMonitorResource", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}" - } + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ElasticMonitorResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ElasticMonitorResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, monitor_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -892,40 +906,43 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, monitor_name=monitor_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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( _models.ResourceProviderDefaultErrorResponse, pipeline_response ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> LROPoller[None]: @@ -933,19 +950,11 @@ def begin_delete(self, resource_group_name: str, monitor_name: str, **kwargs: An Delete a monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -959,7 +968,7 @@ def begin_delete(self, resource_group_name: str, monitor_name: str, **kwargs: An lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, monitor_name=monitor_name, api_version=api_version, @@ -968,11 +977,12 @@ def begin_delete(self, resource_group_name: str, monitor_name: str, **kwargs: An params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -981,14 +991,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_open_ai_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_open_ai_operations.py new file mode 100644 index 000000000000..b5c105aba86e --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_open_ai_operations.py @@ -0,0 +1,662 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(resource_group_name: str, monitor_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/openAIIntegrations", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, monitor_name: str, integration_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/openAIIntegrations/{integrationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), + "integrationName": _SERIALIZER.url("integration_name", integration_name, "str", pattern=r"^[a-z][a-z0-9]*$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, monitor_name: str, integration_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/openAIIntegrations/{integrationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), + "integrationName": _SERIALIZER.url("integration_name", integration_name, "str", pattern=r"^[a-z][a-z0-9]*$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, monitor_name: str, integration_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/openAIIntegrations/{integrationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), + "integrationName": _SERIALIZER.url("integration_name", integration_name, "str", pattern=r"^[a-z][a-z0-9]*$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_status_request( + resource_group_name: str, monitor_name: str, integration_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/openAIIntegrations/{integrationName}/getStatus", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), + "integrationName": _SERIALIZER.url("integration_name", integration_name, "str", pattern=r"^[a-z][a-z0-9]*$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class OpenAIOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.elastic.MicrosoftElastic`'s + :attr:`open_ai` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, monitor_name: str, **kwargs: Any + ) -> Iterable["_models.OpenAIIntegrationRPModel"]: + """List OpenAI integration rule for a given monitor resource. + + List OpenAI integration rule for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :return: An iterator like instance of either OpenAIIntegrationRPModel or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elastic.models.OpenAIIntegrationRPModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OpenAIIntegrationRPModelListResponse] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OpenAIIntegrationRPModelListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ResourceProviderDefaultErrorResponse, pipeline_response + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, monitor_name: str, integration_name: str, **kwargs: Any + ) -> _models.OpenAIIntegrationRPModel: + """Get OpenAI integration rule for a given monitor resource. + + Get OpenAI integration rule for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param integration_name: OpenAI Integration name. Required. + :type integration_name: str + :return: OpenAIIntegrationRPModel or the result of cls(response) + :rtype: ~azure.mgmt.elastic.models.OpenAIIntegrationRPModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OpenAIIntegrationRPModel] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + integration_name=integration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ResourceProviderDefaultErrorResponse, pipeline_response + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OpenAIIntegrationRPModel", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + monitor_name: str, + integration_name: str, + body: Optional[_models.OpenAIIntegrationRPModel] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.OpenAIIntegrationRPModel: + """Create or update a OpenAI integration rule for a given monitor resource. + + Create or update a OpenAI integration rule for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param integration_name: OpenAI Integration name. Required. + :type integration_name: str + :param body: Default value is None. + :type body: ~azure.mgmt.elastic.models.OpenAIIntegrationRPModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: OpenAIIntegrationRPModel or the result of cls(response) + :rtype: ~azure.mgmt.elastic.models.OpenAIIntegrationRPModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + monitor_name: str, + integration_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.OpenAIIntegrationRPModel: + """Create or update a OpenAI integration rule for a given monitor resource. + + Create or update a OpenAI integration rule for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param integration_name: OpenAI Integration name. Required. + :type integration_name: str + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: OpenAIIntegrationRPModel or the result of cls(response) + :rtype: ~azure.mgmt.elastic.models.OpenAIIntegrationRPModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + monitor_name: str, + integration_name: str, + body: Optional[Union[_models.OpenAIIntegrationRPModel, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.OpenAIIntegrationRPModel: + """Create or update a OpenAI integration rule for a given monitor resource. + + Create or update a OpenAI integration rule for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param integration_name: OpenAI Integration name. Required. + :type integration_name: str + :param body: Is either a OpenAIIntegrationRPModel type or a IO[bytes] type. Default value is + None. + :type body: ~azure.mgmt.elastic.models.OpenAIIntegrationRPModel or IO[bytes] + :return: OpenAIIntegrationRPModel or the result of cls(response) + :rtype: ~azure.mgmt.elastic.models.OpenAIIntegrationRPModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenAIIntegrationRPModel] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "OpenAIIntegrationRPModel") + else: + _json = None + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + integration_name=integration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ResourceProviderDefaultErrorResponse, pipeline_response + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OpenAIIntegrationRPModel", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, monitor_name: str, integration_name: str, **kwargs: Any + ) -> None: + """Delete OpenAI integration rule for a given monitor resource. + + Delete OpenAI integration rule for a given monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param integration_name: OpenAI Integration name. Required. + :type integration_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + integration_name=integration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ResourceProviderDefaultErrorResponse, pipeline_response + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def get_status( + self, resource_group_name: str, monitor_name: str, integration_name: str, **kwargs: Any + ) -> _models.OpenAIIntegrationStatusResponse: + """Get OpenAI integration status for a given integration. + + Get OpenAI integration status for a given integration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param integration_name: OpenAI Integration name. Required. + :type integration_name: str + :return: OpenAIIntegrationStatusResponse or the result of cls(response) + :rtype: ~azure.mgmt.elastic.models.OpenAIIntegrationStatusResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OpenAIIntegrationStatusResponse] = kwargs.pop("cls", None) + + _request = build_get_status_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + integration_name=integration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ResourceProviderDefaultErrorResponse, pipeline_response + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OpenAIIntegrationStatusResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_operations.py index dbb633cae84e..d0d2f89fda2c 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -80,7 +83,6 @@ def list(self, **kwargs: Any) -> Iterable["_models.OperationResult"]: List all operations provided by Microsoft.Elastic. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elastic.models.OperationResult] :raises ~azure.core.exceptions.HttpResponseError: @@ -91,7 +93,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.OperationResult"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -102,14 +104,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.OperationResult"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _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) else: # make call to next link with the client's api-version @@ -121,13 +121,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -137,11 +136,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Elastic/operations"} diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_organizations_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_organizations_operations.py index def6b8bfb7c7..ec935eb23116 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_organizations_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_organizations_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterator, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -14,19 +16,25 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +46,7 @@ def build_get_api_key_request(subscription_id: str, **kwargs: Any) -> HttpReques _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -50,7 +58,72 @@ def build_get_api_key_request(subscription_id: str, **kwargs: Any) -> HttpReques "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_elastic_to_azure_subscription_mapping_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Elastic/getElasticOrganizationToAzureSubscriptionMapping", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resubscribe_request( + resource_group_name: str, monitor_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/resubscribe", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -98,7 +171,6 @@ def get_api_key( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: UserApiKeyResponse or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.UserApiKeyResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -106,7 +178,7 @@ def get_api_key( @overload def get_api_key( - self, body: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any + self, body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any ) -> _models.UserApiKeyResponse: """Fetch User API Key from internal database, if it was generated and stored while creating the Elasticsearch Organization. @@ -116,11 +188,10 @@ def get_api_key( :param body: Email Id parameter of the User Organization, of which the API Key must be returned. Default value is None. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: UserApiKeyResponse or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.UserApiKeyResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -128,7 +199,7 @@ def get_api_key( @distributed_trace def get_api_key( - self, body: Optional[Union[_models.UserEmailId, IO]] = None, **kwargs: Any + self, body: Optional[Union[_models.UserEmailId, IO[bytes]]] = None, **kwargs: Any ) -> _models.UserApiKeyResponse: """Fetch User API Key from internal database, if it was generated and stored while creating the Elasticsearch Organization. @@ -137,17 +208,13 @@ def get_api_key( Elasticsearch Organization. :param body: Email Id parameter of the User Organization, of which the API Key must be - returned. Is either a UserEmailId type or a IO type. Default value is None. - :type body: ~azure.mgmt.elastic.models.UserEmailId or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + returned. Is either a UserEmailId type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.elastic.models.UserEmailId or IO[bytes] :return: UserApiKeyResponse or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.UserApiKeyResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -165,7 +232,7 @@ def get_api_key( content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: if body is not None: @@ -173,22 +240,20 @@ def get_api_key( else: _json = None - request = build_get_api_key_request( + _request = build_get_api_key_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.get_api_key.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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -200,11 +265,274 @@ def get_api_key( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("UserApiKeyResponse", pipeline_response) + deserialized = self._deserialize("UserApiKeyResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_elastic_to_azure_subscription_mapping( # pylint: disable=name-too-long + self, **kwargs: Any + ) -> _models.ElasticOrganizationToAzureSubscriptionMappingResponse: + """Get Elastic Organization To Azure Subscription Mapping details for the logged-in user. - return deserialized + Get Elastic Organization To Azure Subscription Mapping details for the logged-in user. - get_api_key.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Elastic/getOrganizationApiKey"} + :return: ElasticOrganizationToAzureSubscriptionMappingResponse or the result of cls(response) + :rtype: ~azure.mgmt.elastic.models.ElasticOrganizationToAzureSubscriptionMappingResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ElasticOrganizationToAzureSubscriptionMappingResponse] = kwargs.pop("cls", None) + + _request = build_get_elastic_to_azure_subscription_mapping_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize( + _models.ResourceProviderDefaultErrorResponse, pipeline_response + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "ElasticOrganizationToAzureSubscriptionMappingResponse", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _resubscribe_initial( + self, + resource_group_name: str, + monitor_name: str, + body: Optional[Union[_models.ResubscribeProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "ResubscribeProperties") + else: + _json = None + + _request = build_resubscribe_request( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_resubscribe( + self, + resource_group_name: str, + monitor_name: str, + body: Optional[_models.ResubscribeProperties] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ElasticMonitorResource]: + """Resubscribe the Elasticsearch Organization. + + Resubscribe the Elasticsearch Organization. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param body: Resubscribe Properties. Default value is None. + :type body: ~azure.mgmt.elastic.models.ResubscribeProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either ElasticMonitorResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elastic.models.ElasticMonitorResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_resubscribe( + self, + resource_group_name: str, + monitor_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ElasticMonitorResource]: + """Resubscribe the Elasticsearch Organization. + + Resubscribe the Elasticsearch Organization. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param body: Resubscribe Properties. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either ElasticMonitorResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elastic.models.ElasticMonitorResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_resubscribe( + self, + resource_group_name: str, + monitor_name: str, + body: Optional[Union[_models.ResubscribeProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.ElasticMonitorResource]: + """Resubscribe the Elasticsearch Organization. + + Resubscribe the Elasticsearch Organization. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param monitor_name: Monitor resource name. Required. + :type monitor_name: str + :param body: Resubscribe Properties. Is either a ResubscribeProperties type or a IO[bytes] + type. Default value is None. + :type body: ~azure.mgmt.elastic.models.ResubscribeProperties or IO[bytes] + :return: An instance of LROPoller that returns either ElasticMonitorResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elastic.models.ElasticMonitorResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ElasticMonitorResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._resubscribe_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ElasticMonitorResource", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ElasticMonitorResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ElasticMonitorResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_tag_rules_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_tag_rules_operations.py index 909cb38d4eef..0b03a492fee3 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_tag_rules_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_tag_rules_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -15,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -29,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +48,7 @@ def build_list_request(resource_group_name: str, monitor_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -52,11 +58,13 @@ def build_list_request(resource_group_name: str, monitor_name: str, subscription ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -73,7 +81,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -84,12 +92,14 @@ def build_create_or_update_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), - "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), + "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -108,7 +118,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -118,12 +128,14 @@ def build_get_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), - "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), + "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -140,7 +152,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -150,12 +162,14 @@ def build_delete_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), - "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), + "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -193,12 +207,11 @@ def list( List the tag rules for a given monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MonitoringTagRules or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elastic.models.MonitoringTagRules] :raises ~azure.core.exceptions.HttpResponseError: @@ -209,7 +222,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MonitoringTagRulesListResponse] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -220,17 +233,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, monitor_name=monitor_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) else: # make call to next link with the client's api-version @@ -242,13 +253,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("MonitoringTagRulesListResponse", pipeline_response) @@ -258,11 +268,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -277,10 +287,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/tagRules" - } - @overload def create_or_update( self, @@ -296,8 +302,8 @@ def create_or_update( Create or update a tag rule set for a given monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str @@ -308,7 +314,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: MonitoringTagRules or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.MonitoringTagRules :raises ~azure.core.exceptions.HttpResponseError: @@ -320,7 +325,7 @@ def create_or_update( resource_group_name: str, monitor_name: str, rule_set_name: str, - body: Optional[IO] = None, + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -329,19 +334,18 @@ def create_or_update( Create or update a tag rule set for a given monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param rule_set_name: Tag Rule Set resource name. Required. :type rule_set_name: str :param body: request body of MonitoringTagRules. Default value is None. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: MonitoringTagRules or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.MonitoringTagRules :raises ~azure.core.exceptions.HttpResponseError: @@ -353,32 +357,28 @@ def create_or_update( resource_group_name: str, monitor_name: str, rule_set_name: str, - body: Optional[Union[_models.MonitoringTagRules, IO]] = None, + body: Optional[Union[_models.MonitoringTagRules, IO[bytes]]] = None, **kwargs: Any ) -> _models.MonitoringTagRules: """Create or update a tag rule set for a given monitor resource. Create or update a tag rule set for a given monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param rule_set_name: Tag Rule Set resource name. Required. :type rule_set_name: str - :param body: request body of MonitoringTagRules. Is either a MonitoringTagRules type or a IO - type. Default value is None. - :type body: ~azure.mgmt.elastic.models.MonitoringTagRules or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param body: request body of MonitoringTagRules. Is either a MonitoringTagRules type or a + IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.elastic.models.MonitoringTagRules or IO[bytes] :return: MonitoringTagRules or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.MonitoringTagRules :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -396,7 +396,7 @@ def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: if body is not None: @@ -404,7 +404,7 @@ def create_or_update( else: _json = None - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, monitor_name=monitor_name, rule_set_name=rule_set_name, @@ -413,16 +413,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -434,16 +432,12 @@ def create_or_update( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MonitoringTagRules", pipeline_response) + deserialized = self._deserialize("MonitoringTagRules", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/tagRules/{ruleSetName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -453,19 +447,18 @@ def get( Get a tag rule set for a given monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param rule_set_name: Tag Rule Set resource name. Required. :type rule_set_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: MonitoringTagRules or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.MonitoringTagRules :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -479,22 +472,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MonitoringTagRules] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, monitor_name=monitor_name, rule_set_name=rule_set_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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -506,21 +497,17 @@ def get( ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MonitoringTagRules", pipeline_response) + deserialized = self._deserialize("MonitoringTagRules", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/tagRules/{ruleSetName}" - } + return deserialized # type: ignore - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, monitor_name: str, rule_set_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -532,41 +519,44 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, monitor_name=monitor_name, rule_set_name=rule_set_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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize( _models.ResourceProviderDefaultErrorResponse, pipeline_response ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/tagRules/{ruleSetName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -576,21 +566,13 @@ def begin_delete( Delete a tag rule set for a given monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param rule_set_name: Tag Rule Set resource name. Required. :type rule_set_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -604,7 +586,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, monitor_name=monitor_name, rule_set_name=rule_set_name, @@ -614,11 +596,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -627,14 +610,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/tagRules/{ruleSetName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_traffic_filters_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_traffic_filters_operations.py index 10906efde353..d9bad67d8190 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_traffic_filters_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_traffic_filters_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +48,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -55,11 +58,13 @@ def build_delete_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -99,19 +104,18 @@ def delete( # pylint: disable=inconsistent-return-statements Delete traffic filter from the account. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param ruleset_id: Ruleset Id of the filter. Default value is None. :type ruleset_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -125,22 +129,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, ruleset_id=ruleset_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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -153,8 +155,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/deleteTrafficFilter" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_upgradable_versions_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_upgradable_versions_operations.py index 31b48571ba70..aaf91c7ca142 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_upgradable_versions_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_upgradable_versions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ def build_details_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -50,11 +53,13 @@ def build_details_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -90,17 +95,16 @@ def details(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> List of upgradable versions for a given monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: UpgradableVersionsList or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.UpgradableVersionsList :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -114,21 +118,19 @@ def details(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UpgradableVersionsList] = kwargs.pop("cls", None) - request = build_details_request( + _request = build_details_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.details.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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -140,13 +142,9 @@ def details(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("UpgradableVersionsList", pipeline_response) + deserialized = self._deserialize("UpgradableVersionsList", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - details.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/listUpgradableVersions" - } + return deserialized # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_vm_collection_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_vm_collection_operations.py index 00c04f8cfaf2..c9d66e82889f 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_vm_collection_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_vm_collection_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +44,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -51,11 +55,13 @@ def build_update_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -101,8 +107,8 @@ def update( # pylint: disable=inconsistent-return-statements Update the vm details that will be monitored by the Elastic monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str @@ -111,7 +117,6 @@ def update( # pylint: disable=inconsistent-return-statements :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -122,7 +127,7 @@ def update( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, monitor_name: str, - body: Optional[IO] = None, + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -131,17 +136,16 @@ def update( # pylint: disable=inconsistent-return-statements Update the vm details that will be monitored by the Elastic monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str :param body: VM resource Id. Default value is None. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -152,30 +156,26 @@ def update( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, monitor_name: str, - body: Optional[Union[_models.VMCollectionUpdate, IO]] = None, + body: Optional[Union[_models.VMCollectionUpdate, IO[bytes]]] = None, **kwargs: Any ) -> None: """Update the vm details that will be monitored by the Elastic monitor resource. Update the vm details that will be monitored by the Elastic monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :param body: VM resource Id. Is either a VMCollectionUpdate type or a IO type. Default value is - None. - :type body: ~azure.mgmt.elastic.models.VMCollectionUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param body: VM resource Id. Is either a VMCollectionUpdate type or a IO[bytes] type. Default + value is None. + :type body: ~azure.mgmt.elastic.models.VMCollectionUpdate or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -193,7 +193,7 @@ def update( # pylint: disable=inconsistent-return-statements content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: if body is not None: @@ -201,7 +201,7 @@ def update( # pylint: disable=inconsistent-return-statements else: _json = None - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, @@ -209,16 +209,14 @@ def update( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -231,8 +229,4 @@ def update( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/vmCollectionUpdate" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_vm_host_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_vm_host_operations.py index e30b3b0be992..16158725eaf6 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_vm_host_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_vm_host_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ def build_list_request(resource_group_name: str, monitor_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -50,11 +53,13 @@ def build_list_request(resource_group_name: str, monitor_name: str, subscription ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -90,12 +95,11 @@ def list(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> It List the vm resources currently being monitored by the Elastic monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VMResources or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elastic.models.VMResources] :raises ~azure.core.exceptions.HttpResponseError: @@ -106,7 +110,7 @@ def list(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VMHostListResponse] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -117,17 +121,15 @@ def list(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, monitor_name=monitor_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) else: # make call to next link with the client's api-version @@ -139,13 +141,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("VMHostListResponse", pipeline_response) @@ -155,11 +156,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -173,7 +174,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/listVMHost" - } diff --git a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_vm_ingestion_operations.py b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_vm_ingestion_operations.py index 25fe8184cbfb..438912b29542 100644 --- a/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_vm_ingestion_operations.py +++ b/sdk/elastic/azure-mgmt-elastic/azure/mgmt/elastic/operations/_vm_ingestion_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ def build_details_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -50,11 +53,13 @@ def build_details_request( ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, "str", pattern=r"^.*$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -90,17 +95,16 @@ def details(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> List the vm ingestion details that will be monitored by the Elastic monitor resource. - :param resource_group_name: The name of the resource group to which the Elastic resource - belongs. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param monitor_name: Monitor resource name. Required. :type monitor_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: VMIngestionDetailsResponse or the result of cls(response) :rtype: ~azure.mgmt.elastic.models.VMIngestionDetailsResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -114,21 +118,19 @@ def details(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VMIngestionDetailsResponse] = kwargs.pop("cls", None) - request = build_details_request( + _request = build_details_request( resource_group_name=resource_group_name, monitor_name=monitor_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.details.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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -140,13 +142,9 @@ def details(self, resource_group_name: str, monitor_name: str, **kwargs: Any) -> ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("VMIngestionDetailsResponse", pipeline_response) + deserialized = self._deserialize("VMIngestionDetailsResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - details.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/vmIngestionDetails" - } + return deserialized # type: ignore diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/all_traffic_filters_list.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/all_traffic_filters_list.py index a42374ba3806..e3dcc9948126 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/all_traffic_filters_list.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/all_traffic_filters_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/AllTrafficFilters_list.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/AllTrafficFilters_list.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/associate_traffic_filter_update.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/associate_traffic_filter_update.py index 4ebfacddd958..7aa66bd4af22 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/associate_traffic_filter_update.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/associate_traffic_filter_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -29,13 +30,12 @@ def main(): subscription_id="00000000-0000-0000-0000-000000000000", ) - response = client.associate_traffic_filter.begin_associate( + client.associate_traffic_filter.begin_associate( resource_group_name="myResourceGroup", monitor_name="myMonitor", ).result() - print(response) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/AssociateTrafficFilter_Update.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/AssociateTrafficFilter_Update.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/associated_filters_for_deployment_list.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/associated_filters_for_deployment_list.py index 7fa71659b4f9..4aa96c991f21 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/associated_filters_for_deployment_list.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/associated_filters_for_deployment_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/AssociatedFiltersForDeployment_list.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/AssociatedFiltersForDeployment_list.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/billing_info_get.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/billing_info_get.py new file mode 100644 index 000000000000..5481f8d8b791 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/billing_info_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.elastic import MicrosoftElastic + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-elastic +# USAGE + python billing_info_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MicrosoftElastic( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.billing_info.get( + resource_group_name="myResourceGroup", + monitor_name="myMonitor", + ) + print(response) + + +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/BillingInfo_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/connected_partner_resources_list.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/connected_partner_resources_list.py new file mode 100644 index 000000000000..e6911bb30d3e --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/connected_partner_resources_list.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.elastic import MicrosoftElastic + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-elastic +# USAGE + python connected_partner_resources_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MicrosoftElastic( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.connected_partner_resources.list( + resource_group_name="myResourceGroup", + monitor_name="myMonitor", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/ConnectedPartnerResources_List.json +if __name__ == "__main__": + main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/deployment_info_list.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/deployment_info_list.py index f9f5471d191c..67d0da55ce83 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/deployment_info_list.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/deployment_info_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/DeploymentInfo_List.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/DeploymentInfo_List.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/detach_and_delete_traffic_filter_delete.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/detach_and_delete_traffic_filter_delete.py index 37c3be96b736..78d6ec37a34d 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/detach_and_delete_traffic_filter_delete.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/detach_and_delete_traffic_filter_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -29,13 +30,12 @@ def main(): subscription_id="00000000-0000-0000-0000-000000000000", ) - response = client.detach_and_delete_traffic_filter.delete( + client.detach_and_delete_traffic_filter.delete( resource_group_name="myResourceGroup", monitor_name="myMonitor", ) - print(response) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/DetachAndDeleteTrafficFilter_Delete.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/DetachAndDeleteTrafficFilter_Delete.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/detach_traffic_filters_update.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/detach_traffic_filters_update.py index d1bc562e0155..482ccf6d22d3 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/detach_traffic_filters_update.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/detach_traffic_filters_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -29,13 +30,12 @@ def main(): subscription_id="00000000-0000-0000-0000-000000000000", ) - response = client.detach_traffic_filter.begin_update( + client.detach_traffic_filter.begin_update( resource_group_name="myResourceGroup", monitor_name="myMonitor", ).result() - print(response) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/DetachTrafficFilters_Update.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/DetachTrafficFilters_Update.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/elastic_versions_list.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/elastic_versions_list.py index d25c99d64273..eb542333cf31 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/elastic_versions_list.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/elastic_versions_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/ElasticVersions_List.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/ElasticVersions_List.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/external_user_info.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/external_user_info.py index cb2d81d0f7a2..46c57d68b2fb 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/external_user_info.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/external_user_info.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/ExternalUserInfo.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/ExternalUserInfo.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/ip_traffic_filter_create.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/ip_traffic_filter_create.py index 7c9f06f5823c..fa2318140188 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/ip_traffic_filter_create.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/ip_traffic_filter_create.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -29,13 +30,12 @@ def main(): subscription_id="00000000-0000-0000-0000-000000000000", ) - response = client.create_and_associate_ip_filter.begin_create( + client.create_and_associate_ip_filter.begin_create( resource_group_name="myResourceGroup", monitor_name="myMonitor", ).result() - print(response) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/IPTrafficFilter_Create.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/IPTrafficFilter_Create.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/monitor_upgrade.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitor_upgrade.py index 03933d91bf37..5474db0bd8b6 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/monitor_upgrade.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitor_upgrade.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -29,13 +30,12 @@ def main(): subscription_id="00000000-0000-0000-0000-000000000000", ) - response = client.monitor.begin_upgrade( + client.monitor.begin_upgrade( resource_group_name="myResourceGroup", monitor_name="myMonitor", ).result() - print(response) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/Monitor_Upgrade.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/Monitor_Upgrade.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_resources_list.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_resources_list.py index 34c42022dd53..dbcdb7687b74 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_resources_list.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_resources_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/MonitoredResources_List.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/MonitoredResources_List.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_subscriptions_createor_update.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_subscriptions_createor_update.py new file mode 100644 index 000000000000..c37911ac79dc --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_subscriptions_createor_update.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.elastic import MicrosoftElastic + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-elastic +# USAGE + python monitored_subscriptions_createor_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MicrosoftElastic( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.monitored_subscriptions.begin_createor_update( + resource_group_name="myResourceGroup", + monitor_name="myMonitor", + configuration_name="default", + ).result() + print(response) + + +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/MonitoredSubscriptions_CreateorUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_subscriptions_delete.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_subscriptions_delete.py new file mode 100644 index 000000000000..5cb263f2e5fa --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_subscriptions_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.elastic import MicrosoftElastic + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-elastic +# USAGE + python monitored_subscriptions_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MicrosoftElastic( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.monitored_subscriptions.begin_delete( + resource_group_name="myResourceGroup", + monitor_name="myMonitor", + configuration_name="default", + ).result() + + +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/MonitoredSubscriptions_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_subscriptions_get.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_subscriptions_get.py new file mode 100644 index 000000000000..baed150cb809 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_subscriptions_get.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.elastic import MicrosoftElastic + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-elastic +# USAGE + python monitored_subscriptions_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MicrosoftElastic( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.monitored_subscriptions.get( + resource_group_name="myResourceGroup", + monitor_name="myMonitor", + configuration_name="default", + ) + print(response) + + +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/MonitoredSubscriptions_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_subscriptions_list.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_subscriptions_list.py new file mode 100644 index 000000000000..ea1583311b1e --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_subscriptions_list.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.elastic import MicrosoftElastic + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-elastic +# USAGE + python monitored_subscriptions_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MicrosoftElastic( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.monitored_subscriptions.list( + resource_group_name="myResourceGroup", + monitor_name="myMonitor", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/MonitoredSubscriptions_List.json +if __name__ == "__main__": + main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_subscriptions_update.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_subscriptions_update.py new file mode 100644 index 000000000000..ff7afda09f7c --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitored_subscriptions_update.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.elastic import MicrosoftElastic + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-elastic +# USAGE + python monitored_subscriptions_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MicrosoftElastic( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.monitored_subscriptions.begin_update( + resource_group_name="myResourceGroup", + monitor_name="myMonitor", + configuration_name="default", + ).result() + print(response) + + +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/MonitoredSubscriptions_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_create.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_create.py index 97bec945a017..b527e7e50e8b 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_create.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_create.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/Monitors_Create.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/Monitors_Create.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_delete.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_delete.py index e618dbfeb7b3..1c81296abad1 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_delete.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -29,13 +30,12 @@ def main(): subscription_id="00000000-0000-0000-0000-000000000000", ) - response = client.monitors.begin_delete( + client.monitors.begin_delete( resource_group_name="myResourceGroup", monitor_name="myMonitor", ).result() - print(response) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/Monitors_Delete.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/Monitors_Delete.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_get.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_get.py index 2374996c0997..7690c85e3b91 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_get.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/Monitors_Get.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/Monitors_Get.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_list.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_list.py index 780a08c79273..5df3410c4204 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_list.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/Monitors_List.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/Monitors_List.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_list_by_resource_group.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_list_by_resource_group.py index 4263efcf6b3c..c691bc50a9fb 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_list_by_resource_group.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_list_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/Monitors_ListByResourceGroup.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/Monitors_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_update.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_update.py index 45f443cf06b8..f458a569771d 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_update.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/monitors_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -29,13 +30,13 @@ def main(): subscription_id="00000000-0000-0000-0000-000000000000", ) - response = client.monitors.update( + response = client.monitors.begin_update( resource_group_name="myResourceGroup", monitor_name="myMonitor", - ) + ).result() print(response) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/Monitors_Update.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/Monitors_Update.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/open_ai_create_or_update.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/open_ai_create_or_update.py new file mode 100644 index 000000000000..b1bcd14e2f29 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/open_ai_create_or_update.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.elastic import MicrosoftElastic + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-elastic +# USAGE + python open_ai_create_or_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MicrosoftElastic( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.open_ai.create_or_update( + resource_group_name="myResourceGroup", + monitor_name="myMonitor", + integration_name="default", + ) + print(response) + + +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/OpenAI_CreateOrUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/open_ai_delete.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/open_ai_delete.py new file mode 100644 index 000000000000..53e0453e22db --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/open_ai_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.elastic import MicrosoftElastic + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-elastic +# USAGE + python open_ai_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MicrosoftElastic( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.open_ai.delete( + resource_group_name="myResourceGroup", + monitor_name="myMonitor", + integration_name="default", + ) + + +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/OpenAI_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/open_ai_get.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/open_ai_get.py new file mode 100644 index 000000000000..f16cc25b92b6 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/open_ai_get.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.elastic import MicrosoftElastic + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-elastic +# USAGE + python open_ai_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MicrosoftElastic( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.open_ai.get( + resource_group_name="myResourceGroup", + monitor_name="myMonitor", + integration_name="default", + ) + print(response) + + +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/OpenAI_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/open_ai_get_status.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/open_ai_get_status.py new file mode 100644 index 000000000000..b91fe62cd23f --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/open_ai_get_status.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.elastic import MicrosoftElastic + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-elastic +# USAGE + python open_ai_get_status.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MicrosoftElastic( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.open_ai.get_status( + resource_group_name="myResourceGroup", + monitor_name="myMonitor", + integration_name="default", + ) + print(response) + + +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/OpenAI_GetStatus.json +if __name__ == "__main__": + main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/open_ai_list.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/open_ai_list.py new file mode 100644 index 000000000000..572def992140 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/open_ai_list.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.elastic import MicrosoftElastic + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-elastic +# USAGE + python open_ai_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MicrosoftElastic( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.open_ai.list( + resource_group_name="myResourceGroup", + monitor_name="myMonitor", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/OpenAI_List.json +if __name__ == "__main__": + main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/operations_list.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/operations_list.py index 789d816651c8..5424d79daab7 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/operations_list.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/operations_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/Operations_List.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/Operations_List.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/organizations_get_api_key.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/organizations_get_api_key.py index c890fc4eea4f..53e559166e92 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/organizations_get_api_key.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/organizations_get_api_key.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -33,6 +34,6 @@ def main(): print(response) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/Organizations_GetApiKey.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/Organizations_GetApiKey.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/organizations_get_elastic_to_azure_subscription_mapping.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/organizations_get_elastic_to_azure_subscription_mapping.py new file mode 100644 index 000000000000..093826d26579 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/organizations_get_elastic_to_azure_subscription_mapping.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.elastic import MicrosoftElastic + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-elastic +# USAGE + python organizations_get_elastic_to_azure_subscription_mapping.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MicrosoftElastic( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.organizations.get_elastic_to_azure_subscription_mapping() + print(response) + + +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/Organizations_GetElasticToAzureSubscriptionMapping.json +if __name__ == "__main__": + main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/organizations_resubscribe.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/organizations_resubscribe.py new file mode 100644 index 000000000000..7181265c7c2e --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/organizations_resubscribe.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.elastic import MicrosoftElastic + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-elastic +# USAGE + python organizations_resubscribe.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MicrosoftElastic( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.organizations.begin_resubscribe( + resource_group_name="myResourceGroup", + monitor_name="myMonitor", + ).result() + print(response) + + +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/Organizations_Resubscribe.json +if __name__ == "__main__": + main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/private_link_traffic_filters_create.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/private_link_traffic_filters_create.py index 6fc1a55f2f98..3dedfae4795a 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/private_link_traffic_filters_create.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/private_link_traffic_filters_create.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -29,13 +30,12 @@ def main(): subscription_id="00000000-0000-0000-0000-000000000000", ) - response = client.create_and_associate_pl_filter.begin_create( + client.create_and_associate_pl_filter.begin_create( resource_group_name="myResourceGroup", monitor_name="myMonitor", ).result() - print(response) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/PrivateLinkTrafficFilters_Create.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/PrivateLinkTrafficFilters_Create.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/tag_rules_create_or_update.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/tag_rules_create_or_update.py index f16175babc31..6400b1cb1cb9 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/tag_rules_create_or_update.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/tag_rules_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/TagRules_CreateOrUpdate.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/TagRules_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/tag_rules_delete.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/tag_rules_delete.py index 07be4c529575..930a2966e40e 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/tag_rules_delete.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/tag_rules_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -29,14 +30,13 @@ def main(): subscription_id="00000000-0000-0000-0000-000000000000", ) - response = client.tag_rules.begin_delete( + client.tag_rules.begin_delete( resource_group_name="myResourceGroup", monitor_name="myMonitor", rule_set_name="default", ).result() - print(response) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/TagRules_Delete.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/TagRules_Delete.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/tag_rules_get.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/tag_rules_get.py index ac3e4b327080..6928079f3141 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/tag_rules_get.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/tag_rules_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/TagRules_Get.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/TagRules_Get.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/tag_rules_list.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/tag_rules_list.py index 4635af09ee15..36af2daee889 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/tag_rules_list.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/tag_rules_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/TagRules_List.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/TagRules_List.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/traffic_filters_delete.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/traffic_filters_delete.py index 12d2890ec1b8..b81afeeda88f 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/traffic_filters_delete.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/traffic_filters_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -29,13 +30,12 @@ def main(): subscription_id="00000000-0000-0000-0000-000000000000", ) - response = client.traffic_filters.delete( + client.traffic_filters.delete( resource_group_name="myResourceGroup", monitor_name="myMonitor", ) - print(response) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/TrafficFilters_Delete.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/TrafficFilters_Delete.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/upgradable_versions_details.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/upgradable_versions_details.py index 9760ac3fc9ad..61424cb989d7 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/upgradable_versions_details.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/upgradable_versions_details.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/UpgradableVersions_Details.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/UpgradableVersions_Details.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/vm_collection_update.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/vm_collection_update.py index 46d2923474a9..320928b48bbc 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/vm_collection_update.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/vm_collection_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -29,13 +30,12 @@ def main(): subscription_id="00000000-0000-0000-0000-000000000000", ) - response = client.vm_collection.update( + client.vm_collection.update( resource_group_name="myResourceGroup", monitor_name="myMonitor", ) - print(response) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/VMCollection_Update.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/VMCollection_Update.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/vm_host_list.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/vm_host_list.py index 377cd922c9c5..e48fb87c500f 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/vm_host_list.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/vm_host_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/VMHost_List.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/VMHost_List.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_samples/vm_ingestion_details.py b/sdk/elastic/azure-mgmt-elastic/generated_samples/vm_ingestion_details.py index 88b44f9d902e..559be6fe961e 100644 --- a/sdk/elastic/azure-mgmt-elastic/generated_samples/vm_ingestion_details.py +++ b/sdk/elastic/azure-mgmt-elastic/generated_samples/vm_ingestion_details.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elastic import MicrosoftElastic """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2023-02-01-preview/examples/VMIngestion_Details.json +# x-ms-original-file: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-10-01-preview/examples/VMIngestion_Details.json if __name__ == "__main__": main() diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/conftest.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/conftest.py new file mode 100644 index 000000000000..d03a078ad93b --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + microsoftelastic_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + microsoftelastic_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + microsoftelastic_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + microsoftelastic_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=microsoftelastic_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=microsoftelastic_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=microsoftelastic_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=microsoftelastic_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_all_traffic_filters_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_all_traffic_filters_operations.py new file mode 100644 index 000000000000..f3e3b3f08aae --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_all_traffic_filters_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticAllTrafficFiltersOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.all_traffic_filters.list( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_all_traffic_filters_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_all_traffic_filters_operations_async.py new file mode 100644 index 000000000000..6c2290fd7b17 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_all_traffic_filters_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticAllTrafficFiltersOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = await self.client.all_traffic_filters.list( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_associate_traffic_filter_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_associate_traffic_filter_operations.py new file mode 100644 index 000000000000..34b6dfe75f26 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_associate_traffic_filter_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticAssociateTrafficFilterOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_associate(self, resource_group): + response = self.client.associate_traffic_filter.begin_associate( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_associate_traffic_filter_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_associate_traffic_filter_operations_async.py new file mode 100644 index 000000000000..7c590bccae11 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_associate_traffic_filter_operations_async.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticAssociateTrafficFilterOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_associate(self, resource_group): + response = await ( + await self.client.associate_traffic_filter.begin_associate( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_billing_info_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_billing_info_operations.py new file mode 100644 index 000000000000..419b0cd803d8 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_billing_info_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticBillingInfoOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.billing_info.get( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_billing_info_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_billing_info_operations_async.py new file mode 100644 index 000000000000..740083601283 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_billing_info_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticBillingInfoOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.billing_info.get( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_connected_partner_resources_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_connected_partner_resources_operations.py new file mode 100644 index 000000000000..d388dbcc944c --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_connected_partner_resources_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticConnectedPartnerResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.connected_partner_resources.list( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_connected_partner_resources_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_connected_partner_resources_operations_async.py new file mode 100644 index 000000000000..0bb50ef72882 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_connected_partner_resources_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticConnectedPartnerResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.connected_partner_resources.list( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_create_and_associate_ip_filter_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_create_and_associate_ip_filter_operations.py new file mode 100644 index 000000000000..29cf266d117c --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_create_and_associate_ip_filter_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticCreateAndAssociateIPFilterOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.create_and_associate_ip_filter.begin_create( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_create_and_associate_ip_filter_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_create_and_associate_ip_filter_operations_async.py new file mode 100644 index 000000000000..ac443044352d --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_create_and_associate_ip_filter_operations_async.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticCreateAndAssociateIPFilterOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.create_and_associate_ip_filter.begin_create( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_create_and_associate_pl_filter_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_create_and_associate_pl_filter_operations.py new file mode 100644 index 000000000000..420de15e8871 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_create_and_associate_pl_filter_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticCreateAndAssociatePLFilterOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.create_and_associate_pl_filter.begin_create( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_create_and_associate_pl_filter_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_create_and_associate_pl_filter_operations_async.py new file mode 100644 index 000000000000..43f8bde8f0b8 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_create_and_associate_pl_filter_operations_async.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticCreateAndAssociatePLFilterOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.create_and_associate_pl_filter.begin_create( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_deployment_info_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_deployment_info_operations.py new file mode 100644 index 000000000000..d66f1beacbdc --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_deployment_info_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticDeploymentInfoOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.deployment_info.list( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_deployment_info_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_deployment_info_operations_async.py new file mode 100644 index 000000000000..4eb0ee6429ad --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_deployment_info_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticDeploymentInfoOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = await self.client.deployment_info.list( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_detach_and_delete_traffic_filter_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_detach_and_delete_traffic_filter_operations.py new file mode 100644 index 000000000000..e20b30c41a74 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_detach_and_delete_traffic_filter_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticDetachAndDeleteTrafficFilterOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.detach_and_delete_traffic_filter.delete( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_detach_and_delete_traffic_filter_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_detach_and_delete_traffic_filter_operations_async.py new file mode 100644 index 000000000000..7e7a6865ffc6 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_detach_and_delete_traffic_filter_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticDetachAndDeleteTrafficFilterOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.detach_and_delete_traffic_filter.delete( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_detach_traffic_filter_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_detach_traffic_filter_operations.py new file mode 100644 index 000000000000..9143ca4de506 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_detach_traffic_filter_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticDetachTrafficFilterOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.detach_traffic_filter.begin_update( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_detach_traffic_filter_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_detach_traffic_filter_operations_async.py new file mode 100644 index 000000000000..ba97b099c6d6 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_detach_traffic_filter_operations_async.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticDetachTrafficFilterOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.detach_traffic_filter.begin_update( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_elastic_versions_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_elastic_versions_operations.py new file mode 100644 index 000000000000..c594a7fc6da8 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_elastic_versions_operations.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticElasticVersionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.elastic_versions.list( + region="str", + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_elastic_versions_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_elastic_versions_operations_async.py new file mode 100644 index 000000000000..9e96ae95a571 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_elastic_versions_operations_async.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticElasticVersionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.elastic_versions.list( + region="str", + api_version="2024-10-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_external_user_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_external_user_operations.py new file mode 100644 index 000000000000..3718d4f2702c --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_external_user_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticExternalUserOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.external_user.create_or_update( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_external_user_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_external_user_operations_async.py new file mode 100644 index 000000000000..8651e0f65852 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_external_user_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticExternalUserOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.external_user.create_or_update( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_list_associated_traffic_filters_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_list_associated_traffic_filters_operations.py new file mode 100644 index 000000000000..a3d508c7ea6d --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_list_associated_traffic_filters_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticListAssociatedTrafficFiltersOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.list_associated_traffic_filters.list( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_list_associated_traffic_filters_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_list_associated_traffic_filters_operations_async.py new file mode 100644 index 000000000000..6694606edfc1 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_list_associated_traffic_filters_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticListAssociatedTrafficFiltersOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = await self.client.list_associated_traffic_filters.list( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitor_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitor_operations.py new file mode 100644 index 000000000000..c20c637cd8a1 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitor_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticMonitorOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_upgrade(self, resource_group): + response = self.client.monitor.begin_upgrade( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitor_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitor_operations_async.py new file mode 100644 index 000000000000..73418164ecdb --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitor_operations_async.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticMonitorOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_upgrade(self, resource_group): + response = await ( + await self.client.monitor.begin_upgrade( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitored_resources_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitored_resources_operations.py new file mode 100644 index 000000000000..6fc8317587d8 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitored_resources_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticMonitoredResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.monitored_resources.list( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitored_resources_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitored_resources_operations_async.py new file mode 100644 index 000000000000..ac3fc81030f6 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitored_resources_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticMonitoredResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.monitored_resources.list( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitored_subscriptions_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitored_subscriptions_operations.py new file mode 100644 index 000000000000..3afe4f20f5ba --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitored_subscriptions_operations.py @@ -0,0 +1,83 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticMonitoredSubscriptionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.monitored_subscriptions.list( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.monitored_subscriptions.get( + resource_group_name=resource_group.name, + monitor_name="str", + configuration_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_createor_update(self, resource_group): + response = self.client.monitored_subscriptions.begin_createor_update( + resource_group_name=resource_group.name, + monitor_name="str", + configuration_name="str", + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.monitored_subscriptions.begin_update( + resource_group_name=resource_group.name, + monitor_name="str", + configuration_name="str", + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.monitored_subscriptions.begin_delete( + resource_group_name=resource_group.name, + monitor_name="str", + configuration_name="str", + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitored_subscriptions_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitored_subscriptions_operations_async.py new file mode 100644 index 000000000000..5c9a169ffd0c --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitored_subscriptions_operations_async.py @@ -0,0 +1,90 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticMonitoredSubscriptionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.monitored_subscriptions.list( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.monitored_subscriptions.get( + resource_group_name=resource_group.name, + monitor_name="str", + configuration_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_createor_update(self, resource_group): + response = await ( + await self.client.monitored_subscriptions.begin_createor_update( + resource_group_name=resource_group.name, + monitor_name="str", + configuration_name="str", + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.monitored_subscriptions.begin_update( + resource_group_name=resource_group.name, + monitor_name="str", + configuration_name="str", + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.monitored_subscriptions.begin_delete( + resource_group_name=resource_group.name, + monitor_name="str", + configuration_name="str", + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitors_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitors_operations.py new file mode 100644 index 000000000000..6fde6b1584a6 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitors_operations.py @@ -0,0 +1,88 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticMonitorsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.monitors.list( + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.monitors.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.monitors.get( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.monitors.begin_create( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.monitors.begin_update( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.monitors.begin_delete( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitors_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitors_operations_async.py new file mode 100644 index 000000000000..3ecf0e72ddae --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_monitors_operations_async.py @@ -0,0 +1,95 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticMonitorsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.monitors.list( + api_version="2024-10-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.monitors.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-10-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.monitors.get( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.monitors.begin_create( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.monitors.begin_update( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.monitors.begin_delete( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_open_ai_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_open_ai_operations.py new file mode 100644 index 000000000000..f147b9097cfe --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_open_ai_operations.py @@ -0,0 +1,83 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticOpenAIOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.open_ai.list( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.open_ai.get( + resource_group_name=resource_group.name, + monitor_name="str", + integration_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.open_ai.create_or_update( + resource_group_name=resource_group.name, + monitor_name="str", + integration_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.open_ai.delete( + resource_group_name=resource_group.name, + monitor_name="str", + integration_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_status(self, resource_group): + response = self.client.open_ai.get_status( + resource_group_name=resource_group.name, + monitor_name="str", + integration_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_open_ai_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_open_ai_operations_async.py new file mode 100644 index 000000000000..8f43a27e79b7 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_open_ai_operations_async.py @@ -0,0 +1,84 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticOpenAIOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.open_ai.list( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.open_ai.get( + resource_group_name=resource_group.name, + monitor_name="str", + integration_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.open_ai.create_or_update( + resource_group_name=resource_group.name, + monitor_name="str", + integration_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.open_ai.delete( + resource_group_name=resource_group.name, + monitor_name="str", + integration_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_status(self, resource_group): + response = await self.client.open_ai.get_status( + resource_group_name=resource_group.name, + monitor_name="str", + integration_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_operations.py new file mode 100644 index 000000000000..a9051c65e4dd --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_operations_async.py new file mode 100644 index 000000000000..bbb93f32508b --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-10-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_organizations_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_organizations_operations.py new file mode 100644 index 000000000000..6b1c0fef49ce --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_organizations_operations.py @@ -0,0 +1,51 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticOrganizationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_api_key(self, resource_group): + response = self.client.organizations.get_api_key( + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_elastic_to_azure_subscription_mapping(self, resource_group): + response = self.client.organizations.get_elastic_to_azure_subscription_mapping( + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_resubscribe(self, resource_group): + response = self.client.organizations.begin_resubscribe( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_organizations_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_organizations_operations_async.py new file mode 100644 index 000000000000..cd3c4e053071 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_organizations_operations_async.py @@ -0,0 +1,54 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticOrganizationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_api_key(self, resource_group): + response = await self.client.organizations.get_api_key( + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_elastic_to_azure_subscription_mapping(self, resource_group): + response = await self.client.organizations.get_elastic_to_azure_subscription_mapping( + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_resubscribe(self, resource_group): + response = await ( + await self.client.organizations.begin_resubscribe( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_tag_rules_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_tag_rules_operations.py new file mode 100644 index 000000000000..9f7ba6026da3 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_tag_rules_operations.py @@ -0,0 +1,70 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticTagRulesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.tag_rules.list( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.tag_rules.create_or_update( + resource_group_name=resource_group.name, + monitor_name="str", + rule_set_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.tag_rules.get( + resource_group_name=resource_group.name, + monitor_name="str", + rule_set_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.tag_rules.begin_delete( + resource_group_name=resource_group.name, + monitor_name="str", + rule_set_name="str", + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_tag_rules_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_tag_rules_operations_async.py new file mode 100644 index 000000000000..2fab6f20e77e --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_tag_rules_operations_async.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticTagRulesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.tag_rules.list( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.tag_rules.create_or_update( + resource_group_name=resource_group.name, + monitor_name="str", + rule_set_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.tag_rules.get( + resource_group_name=resource_group.name, + monitor_name="str", + rule_set_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.tag_rules.begin_delete( + resource_group_name=resource_group.name, + monitor_name="str", + rule_set_name="str", + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_traffic_filters_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_traffic_filters_operations.py new file mode 100644 index 000000000000..faddf2c7dd3d --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_traffic_filters_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticTrafficFiltersOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.traffic_filters.delete( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_traffic_filters_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_traffic_filters_operations_async.py new file mode 100644 index 000000000000..00d1749958eb --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_traffic_filters_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticTrafficFiltersOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.traffic_filters.delete( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_upgradable_versions_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_upgradable_versions_operations.py new file mode 100644 index 000000000000..5f5f4813a92f --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_upgradable_versions_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticUpgradableVersionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_details(self, resource_group): + response = self.client.upgradable_versions.details( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_upgradable_versions_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_upgradable_versions_operations_async.py new file mode 100644 index 000000000000..47fc7646e72e --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_upgradable_versions_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticUpgradableVersionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_details(self, resource_group): + response = await self.client.upgradable_versions.details( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_collection_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_collection_operations.py new file mode 100644 index 000000000000..9c15b704f8bf --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_collection_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticVMCollectionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.vm_collection.update( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_collection_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_collection_operations_async.py new file mode 100644 index 000000000000..727d343eae0d --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_collection_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticVMCollectionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.vm_collection.update( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_host_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_host_operations.py new file mode 100644 index 000000000000..ce3fda851e87 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_host_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticVMHostOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.vm_host.list( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_host_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_host_operations_async.py new file mode 100644 index 000000000000..376e8a165d4b --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_host_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticVMHostOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.vm_host.list( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_ingestion_operations.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_ingestion_operations.py new file mode 100644 index 000000000000..4a715c8016c4 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_ingestion_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticVMIngestionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_details(self, resource_group): + response = self.client.vm_ingestion.details( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_ingestion_operations_async.py b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_ingestion_operations_async.py new file mode 100644 index 000000000000..664cd4a778d2 --- /dev/null +++ b/sdk/elastic/azure-mgmt-elastic/generated_tests/test_microsoft_elastic_vm_ingestion_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elastic.aio import MicrosoftElastic + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMicrosoftElasticVMIngestionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MicrosoftElastic, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_details(self, resource_group): + response = await self.client.vm_ingestion.details( + resource_group_name=resource_group.name, + monitor_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elastic/azure-mgmt-elastic/setup.py b/sdk/elastic/azure-mgmt-elastic/setup.py index 929bd9512951..388f25f41b7a 100644 --- a/sdk/elastic/azure-mgmt-elastic/setup.py +++ b/sdk/elastic/azure-mgmt-elastic/setup.py @@ -1,10 +1,10 @@ #!/usr/bin/env python -#------------------------------------------------------------------------- +# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. -#-------------------------------------------------------------------------- +# -------------------------------------------------------------------------- import re import os.path @@ -16,64 +16,68 @@ PACKAGE_PPRINT_NAME = "Elastic Management" # a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace('-', '/') +package_folder_path = PACKAGE_NAME.replace("-", "/") # a-b-c => a.b.c -namespace_name = PACKAGE_NAME.replace('-', '.') +namespace_name = PACKAGE_NAME.replace("-", ".") # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, 'version.py') - if os.path.exists(os.path.join(package_folder_path, 'version.py')) - else os.path.join(package_folder_path, '_version.py'), 'r') as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', - fd.read(), re.MULTILINE).group(1) +with open( + os.path.join(package_folder_path, "version.py") + if os.path.exists(os.path.join(package_folder_path, "version.py")) + else os.path.join(package_folder_path, "_version.py"), + "r", +) as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) if not version: - raise RuntimeError('Cannot find version information') + raise RuntimeError("Cannot find version information") -with open('README.md', encoding='utf-8') as f: +with open("README.md", encoding="utf-8") as f: readme = f.read() -with open('CHANGELOG.md', encoding='utf-8') as f: +with open("CHANGELOG.md", encoding="utf-8") as f: changelog = f.read() setup( name=PACKAGE_NAME, version=version, - description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), - long_description=readme + '\n\n' + changelog, - long_description_content_type='text/markdown', - license='MIT License', - author='Microsoft Corporation', - author_email='azpysdkhelp@microsoft.com', - url='https://github.com/Azure/azure-sdk-for-python', + description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=readme + "\n\n" + changelog, + long_description_content_type="text/markdown", + license="MIT License", + author="Microsoft Corporation", + author_email="azpysdkhelp@microsoft.com", + url="https://github.com/Azure/azure-sdk-for-python", keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product classifiers=[ - 'Development Status :: 4 - Beta', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'License :: OSI Approved :: MIT License', + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "License :: OSI Approved :: MIT License", ], zip_safe=False, - packages=find_packages(exclude=[ - 'tests', - # Exclude packages that will be covered by PEP420 or nspkg - 'azure', - 'azure.mgmt', - ]), + packages=find_packages( + exclude=[ + "tests", + # Exclude packages that will be covered by PEP420 or nspkg + "azure", + "azure.mgmt", + ] + ), include_package_data=True, package_data={ - 'pytyped': ['py.typed'], + "pytyped": ["py.typed"], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", - "typing-extensions>=4.3.0; python_version<'3.8.0'", + "isodate>=0.6.1", + "typing-extensions>=4.6.0", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], - python_requires=">=3.7" + python_requires=">=3.8", )