diff --git a/.vscode/cspell.json b/.vscode/cspell.json index aac83516f7d8..85a0cb572df4 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -447,6 +447,12 @@ "undoc" ] }, + { + "filename": "sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/**", + "words":[ + "vusers" + ] + }, { "filename": "sdk/ml/azure-ai-ml/**", "words": [ diff --git a/eng/tox/allowed_pylint_failures.py b/eng/tox/allowed_pylint_failures.py index a2421870ded3..bdbf42094832 100644 --- a/eng/tox/allowed_pylint_failures.py +++ b/eng/tox/allowed_pylint_failures.py @@ -59,5 +59,6 @@ "azure-messaging-nspkg", "azure-agrifood-farming", "azure-ai-language-questionanswering", - "azure-ai-language-conversations" + "azure-ai-language-conversations", + "azure-analytics-loadtestservice" ] diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/CHANGELOG.md b/sdk/loadtestservice/azure-analytics-loadtestservice/CHANGELOG.md new file mode 100644 index 000000000000..8e69fada491d --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/CHANGELOG.md @@ -0,0 +1,6 @@ +# Release History + +## 1.0.0b1 (2022-07-05) + +- Initial version + diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/LICENSE b/sdk/loadtestservice/azure-analytics-loadtestservice/LICENSE new file mode 100644 index 000000000000..b2f52a2bad4e --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Microsoft Corporation. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/MANIFEST.in b/sdk/loadtestservice/azure-analytics-loadtestservice/MANIFEST.in new file mode 100644 index 000000000000..ad98bf92c7c6 --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/MANIFEST.in @@ -0,0 +1,7 @@ +include *.md +include azure/__init__.py +include azure/analytics/__init__.py +include LICENSE +recursive-include tests *.py +recursive-include samples *.py *.md +include azure/analytics/loadtestservice/py.typed \ No newline at end of file diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/README.md b/sdk/loadtestservice/azure-analytics-loadtestservice/README.md new file mode 100644 index 000000000000..0e94e702fc54 --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/README.md @@ -0,0 +1,115 @@ +# Azure Analytics LoadTestService client library for Python +Azure Analytics LoadTestService provides client library in python to the user by which they can interact natively with Load Test Service.The service is for performing the load test to optimize application performance, scalability or capacity. The user can get the client-side and server-side metrices to see the details reported by the test engine and information about your Azure application components. + +## _Disclaimer_ + +_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please +refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ + +## Getting started + +### Installating the package + +```bash +python -m pip install azure-analytics-loadtestservice +``` + +#### Prequisites + +- Python 3.6 or later is required to use this package. +- You need an [Azure subscription][azure_sub] to use this package. +- An existing Azure Analytics LoadTestService instance. + +#### Create with an Azure Active Directory Credential +To use an [Azure Active Directory (AAD) token credential][authenticate_with_token], +provide an instance of the desired credential type obtained from the +[azure-identity][azure_identity_credentials] library. + +To authenticate with AAD, you must first [pip][pip] install [`azure-identity`][azure_identity_pip] + +After setup, you can choose which type of [credential][azure_identity_credentials] from azure.identity to use. +As an example, [DefaultAzureCredential][default_azure_credential] can be used to authenticate the client: + +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` + +Use the returned token credential to authenticate the client: + +```python +>>> from azure.analytics.loadtestservice import LoadTestClient +>>> from azure.identity import DefaultAzureCredential +>>> client = LoadTestClient(endpoint='', credential=DefaultAzureCredential()) +``` + +## Examples + +```python +>>> from azure.analytics.loadtestservice import LoadTestClient +>>> from azure.identity import DefaultAzureCredential +>>> from azure.core.exceptions import HttpResponseError + +>>> client = LoadTestClient(endpoint='', credential=DefaultAzureCredential()) +>>> try: + result = client.test.list_load_test_search() + print(result) + except HttpResponseError as e: + print('service responds error: {}'.format(e.response.json())) +``` + +## Key concepts +The following components make up the Azure Load Testing Service. The Azure Load Test client library for Python allows you to interact with each of these components through the use of a dedicated client object. + +### Load testing resource +The Load testing resource is the top-level resource for your load-testing activities. This resource provides a centralized place to view and manage load tests, test results, and related artifacts. A load testing resource contains zero or more load tests. + +### Test +A test specifies the test script, and configuration settings for running a load test. You can create one or more tests in an Azure Load Testing resource. + +### Test Engine +A test engine is computing infrastructure that runs the Apache JMeter test script. You can scale out your load test by configuring the number of test engines. The test script runs in parallel across the specified number of test engines. + +### Test Run +A test run represents one execution of a load test. It collects the logs associated with running the Apache JMeter script, the load test YAML configuration, the list of app components to monitor, and the results of the test. + +### App Component +When you run a load test for an Azure-hosted application, you can monitor resource metrics for the different Azure application components (server-side metrics). While the load test runs, and after completion of the test, you can monitor and analyze the resource metrics in the Azure Load Testing dashboard. + +### Metrics +During a load test, Azure Load Testing collects metrics about the test execution. There are two types of metrics: + +1. Client-side metrics give you details reported by the test engine. These metrics include the number of virtual users, the request response time, the number of failed requests, or the number of requests per second. + +2. Server-side metrics are available for Azure-hosted applications and provide information about your Azure application components. Metrics can be for the number of database reads, the type of HTTP responses, or container resource consumption. + +## Troubleshooting +More about it is coming soon... + +## Next steps + +More examples are coming soon... + +## Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit https://cla.microsoft.com. + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information, +see the Code of Conduct FAQ or contact opencode@microsoft.com with any +additional questions or comments. + + +[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/ +[authenticate_with_token]: https://docs.microsoft.com/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-an-authentication-token +[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#credentials +[azure_identity_pip]: https://pypi.org/project/azure-identity/ +[default_azure_credential]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#defaultazurecredential +[pip]: https://pypi.org/project/pip/ +[azure_sub]: https://azure.microsoft.com/free/ diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/azure/__init__.py b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/__init__.py b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/__init__.py b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/__init__.py new file mode 100644 index 000000000000..10a088db75dd --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/__init__.py @@ -0,0 +1,23 @@ +# 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 ._client import LoadTestClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['LoadTestClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/_client.py b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/_client.py new file mode 100644 index 000000000000..7ae73a8893f1 --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/_client.py @@ -0,0 +1,111 @@ +# 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 copy import deepcopy +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core import PipelineClient +from azure.core.rest import HttpRequest, HttpResponse + +from ._configuration import LoadTestClientConfiguration +from .operations import AppComponentOperations, ServerMetricsOperations, TestOperations, TestRunOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + from azure.core.credentials import TokenCredential + +class LoadTestClient: # pylint: disable=client-accepts-api-version-keyword + """These APIs allow end users to create, view and run load tests using Azure Load Test Service. + + :ivar app_component: AppComponentOperations operations + :vartype app_component: azure.analytics.loadtestservice.operations.AppComponentOperations + :ivar server_metrics: ServerMetricsOperations operations + :vartype server_metrics: azure.analytics.loadtestservice.operations.ServerMetricsOperations + :ivar test: TestOperations operations + :vartype test: azure.analytics.loadtestservice.operations.TestOperations + :ivar test_run: TestRunOperations operations + :vartype test_run: azure.analytics.loadtestservice.operations.TestRunOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :keyword endpoint: Service URL. Default value is "https://". + :paramtype endpoint: str + :keyword api_version: Api Version. Default value is "2022-06-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + *, + endpoint: str = "https://", + **kwargs: Any + ) -> None: + + self._config = LoadTestClientConfiguration(credential=credential, **kwargs) + self._client = PipelineClient(base_url=endpoint, config=self._config, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + self.app_component = AppComponentOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.server_metrics = ServerMetricsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.test = TestOperations( # type: ignore # pylint: disable=abstract-class-instantiated + self._client, self._config, self._serialize, self._deserialize + ) + self.test_run = TestRunOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + def send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> LoadTestClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/_configuration.py b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/_configuration.py new file mode 100644 index 000000000000..e3a0c279b115 --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/_configuration.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class LoadTestClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for LoadTestClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :keyword api_version: Api Version. Default value is "2022-06-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + **kwargs: Any + ) -> None: + super(LoadTestClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-06-01-preview") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.credential = credential + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://loadtest.azure-dev.com/.default']) + kwargs.setdefault('sdk_moniker', 'analytics-loadtestservice/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/_patch.py b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/_vendor.py b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/_vendor.py new file mode 100644 index 000000000000..e12b61dea670 --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/_vendor.py @@ -0,0 +1,21 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + + + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/_version.py b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/aio/__init__.py b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/aio/__init__.py new file mode 100644 index 000000000000..6b69aab79676 --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/aio/__init__.py @@ -0,0 +1,20 @@ +# 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 ._client import LoadTestClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['LoadTestClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/aio/_client.py b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/aio/_client.py new file mode 100644 index 000000000000..9f5a6c6d9d2b --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/aio/_client.py @@ -0,0 +1,107 @@ +# 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 copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core import AsyncPipelineClient +from azure.core.rest import AsyncHttpResponse, HttpRequest + +from ._configuration import LoadTestClientConfiguration +from .operations import AppComponentOperations, ServerMetricsOperations, TestOperations, TestRunOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + from azure.core.credentials_async import AsyncTokenCredential + +class LoadTestClient: # pylint: disable=client-accepts-api-version-keyword + """These APIs allow end users to create, view and run load tests using Azure Load Test Service. + + :ivar app_component: AppComponentOperations operations + :vartype app_component: azure.analytics.loadtestservice.aio.operations.AppComponentOperations + :ivar server_metrics: ServerMetricsOperations operations + :vartype server_metrics: azure.analytics.loadtestservice.aio.operations.ServerMetricsOperations + :ivar test: TestOperations operations + :vartype test: azure.analytics.loadtestservice.aio.operations.TestOperations + :ivar test_run: TestRunOperations operations + :vartype test_run: azure.analytics.loadtestservice.aio.operations.TestRunOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :keyword endpoint: Service URL. Default value is "https://". + :paramtype endpoint: str + :keyword api_version: Api Version. Default value is "2022-06-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + *, + endpoint: str = "https://", + **kwargs: Any + ) -> None: + self._config = LoadTestClientConfiguration(credential=credential, **kwargs) + self._client = AsyncPipelineClient(base_url=endpoint, config=self._config, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + self.app_component = AppComponentOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.server_metrics = ServerMetricsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.test = TestOperations( # type: ignore # pylint: disable=abstract-class-instantiated + self._client, self._config, self._serialize, self._deserialize + ) + self.test_run = TestRunOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + def send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "LoadTestClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/aio/_configuration.py b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/aio/_configuration.py new file mode 100644 index 000000000000..0f07d2bf458b --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/aio/_configuration.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class LoadTestClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for LoadTestClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :keyword api_version: Api Version. Default value is "2022-06-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + **kwargs: Any + ) -> None: + super(LoadTestClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-06-01-preview") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.credential = credential + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://loadtest.azure-dev.com/.default']) + kwargs.setdefault('sdk_moniker', 'analytics-loadtestservice/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/aio/_patch.py b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/aio/operations/__init__.py b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/aio/operations/__init__.py new file mode 100644 index 000000000000..c4cc1df262ad --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/aio/operations/__init__.py @@ -0,0 +1,24 @@ +# 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 ._operations import AppComponentOperations +from ._operations import ServerMetricsOperations +from ._operations import TestOperations +from ._operations import TestRunOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'AppComponentOperations', + 'ServerMetricsOperations', + 'TestOperations', + 'TestRunOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/aio/operations/_operations.py b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/aio/operations/_operations.py new file mode 100644 index 000000000000..6ea8f4f6d5f3 --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/aio/operations/_operations.py @@ -0,0 +1,4937 @@ +# pylint: disable=too-many-lines +# 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 abc +import datetime +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict + +from ...operations._operations import build_app_component_create_or_update_app_components_request, build_app_component_delete_app_component_request, build_app_component_get_app_component_by_name_request, build_app_component_get_app_component_request, build_server_metrics_create_or_update_server_metrics_config_request, build_server_metrics_delete_server_metrics_request, build_server_metrics_get_server_default_metrics_request, build_server_metrics_get_server_metrics_by_name_request, build_server_metrics_get_server_metrics_request, build_server_metrics_list_supported_resource_type_request, build_test_create_or_update_test_request, build_test_delete_load_test_request, build_test_delete_test_file_request, build_test_get_all_test_files_request, build_test_get_load_test_request, build_test_get_test_file_request, build_test_list_load_test_search_request, build_test_run_create_and_update_test_request, build_test_run_delete_test_run_request, build_test_run_get_test_run_client_metrics_filters_request, build_test_run_get_test_run_client_metrics_request, build_test_run_get_test_run_file_request, build_test_run_get_test_run_request, build_test_run_list_test_runs_search_request, build_test_run_stop_test_run_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AppComponentOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.analytics.loadtestservice.aio.LoadTestClient`'s + :attr:`app_component` attribute. + """ + + 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") + + + @overload + async def create_or_update_app_components( + self, + name: str, + body: JSON, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> JSON: + """Associate an App Component (Azure resource) to a test or test run. + + Associate an App Component (Azure resource) to a test or test run. + + :param name: Unique name of the App Component, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type name: str + :param body: App Component model. Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", # Optional. AppComponent name. + "resourceId": "str", # Optional. Azure Load Testing resource Id. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str", # Optional. [Required if testId is not given] Load test + run unique identifier. + "value": { + "str": { + "displayName": "str", # Optional. Azure resource display + name. + "kind": "str", # Optional. Kind of Azure resource type. + "resourceGroup": "str", # Optional. Resource group name of + the Azure resource. + "resourceId": "str", # Fully qualified resource Id e.g + subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + Required. + "resourceName": "str", # Azure resource name. Required. + "resourceType": "str", # Azure resource type. Required. + "subscriptionId": "str" # Optional. Subscription Id of the + Azure resource. + } + } + } + + # response body for status code(s): 200, 201 + response.json() == { + "name": "str", # Optional. AppComponent name. + "resourceId": "str", # Optional. Azure Load Testing resource Id. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str", # Optional. [Required if testId is not given] Load test + run unique identifier. + "value": { + "str": { + "displayName": "str", # Optional. Azure resource display + name. + "kind": "str", # Optional. Kind of Azure resource type. + "resourceGroup": "str", # Optional. Resource group name of + the Azure resource. + "resourceId": "str", # Fully qualified resource Id e.g + subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + Required. + "resourceName": "str", # Azure resource name. Required. + "resourceType": "str", # Azure resource type. Required. + "subscriptionId": "str" # Optional. Subscription Id of the + Azure resource. + } + } + } + """ + + @overload + async def create_or_update_app_components( + self, + name: str, + body: IO, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> JSON: + """Associate an App Component (Azure resource) to a test or test run. + + Associate an App Component (Azure resource) to a test or test run. + + :param name: Unique name of the App Component, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type name: str + :param body: App Component model. Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 201 + response.json() == { + "name": "str", # Optional. AppComponent name. + "resourceId": "str", # Optional. Azure Load Testing resource Id. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str", # Optional. [Required if testId is not given] Load test + run unique identifier. + "value": { + "str": { + "displayName": "str", # Optional. Azure resource display + name. + "kind": "str", # Optional. Kind of Azure resource type. + "resourceGroup": "str", # Optional. Resource group name of + the Azure resource. + "resourceId": "str", # Fully qualified resource Id e.g + subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + Required. + "resourceName": "str", # Azure resource name. Required. + "resourceType": "str", # Azure resource type. Required. + "subscriptionId": "str" # Optional. Subscription Id of the + Azure resource. + } + } + } + """ + + + @distributed_trace_async + async def create_or_update_app_components( + self, + name: str, + body: Union[JSON, IO], + **kwargs: Any + ) -> JSON: + """Associate an App Component (Azure resource) to a test or test run. + + Associate an App Component (Azure resource) to a test or test run. + + :param name: Unique name of the App Component, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type name: str + :param body: App Component model. Is either a model type or a IO type. Required. + :type body: JSON or IO + :keyword content_type: Body Parameter content-type. Known values are: + 'application/merge-patch+json'. Default value is None. + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 201 + response.json() == { + "name": "str", # Optional. AppComponent name. + "resourceId": "str", # Optional. Azure Load Testing resource Id. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str", # Optional. [Required if testId is not given] Load test + run unique identifier. + "value": { + "str": { + "displayName": "str", # Optional. Azure resource display + name. + "kind": "str", # Optional. Kind of Azure resource type. + "resourceGroup": "str", # Optional. Resource group name of + the Azure resource. + "resourceId": "str", # Fully qualified resource Id e.g + subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + Required. + "resourceName": "str", # Azure resource name. Required. + "resourceType": "str", # Azure resource type. Required. + "subscriptionId": "str" # Optional. Subscription Id of the + Azure resource. + } + } + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + content_type = content_type or "application/merge-patch+json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = body + + request = build_app_component_create_or_update_app_components_request( + name=name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 201: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace_async + async def delete_app_component( # pylint: disable=inconsistent-return-statements + self, + name: str, + **kwargs: Any + ) -> None: + """Delete an App Component. + + Delete an App Component. + + :param name: Unique name of the App Component, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_app_component_delete_app_component_request( + name=name, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + + + @distributed_trace_async + async def get_app_component_by_name( + self, + name: str, + **kwargs: Any + ) -> JSON: + """Get App Component details by App Component name. + + Get App Component details by App Component name. + + :param name: Unique name of the App Component, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type name: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "name": "str", # Optional. AppComponent name. + "resourceId": "str", # Optional. Azure Load Testing resource Id. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str", # Optional. [Required if testId is not given] Load test + run unique identifier. + "value": { + "str": { + "displayName": "str", # Optional. Azure resource display + name. + "kind": "str", # Optional. Kind of Azure resource type. + "resourceGroup": "str", # Optional. Resource group name of + the Azure resource. + "resourceId": "str", # Fully qualified resource Id e.g + subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + Required. + "resourceName": "str", # Azure resource name. Required. + "resourceType": "str", # Azure resource type. Required. + "subscriptionId": "str" # Optional. Subscription Id of the + Azure resource. + } + } + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_app_component_get_app_component_by_name_request( + name=name, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace_async + async def get_app_component( + self, + *, + test_run_id: Optional[str] = None, + test_id: Optional[str] = None, + **kwargs: Any + ) -> JSON: + """Get App Components for a test or a test run by its name. + + Get App Components for a test or a test run by its name. + + :keyword test_run_id: [Required, if testId is not provided] Test run Id. Default value is None. + :paramtype test_run_id: str + :keyword test_id: Unique name for load test, must be a valid URL character ^[a-z0-9_-]*$. + Default value is None. + :paramtype test_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "name": "str", # Optional. AppComponent name. + "resourceId": "str", # Optional. Azure Load Testing resource Id. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str", # Optional. [Required if testId is not given] Load test + run unique identifier. + "value": { + "str": { + "displayName": "str", # Optional. Azure resource display + name. + "kind": "str", # Optional. Kind of Azure resource type. + "resourceGroup": "str", # Optional. Resource group name of + the Azure resource. + "resourceId": "str", # Fully qualified resource Id e.g + subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + Required. + "resourceName": "str", # Azure resource name. Required. + "resourceType": "str", # Azure resource type. Required. + "subscriptionId": "str" # Optional. Subscription Id of the + Azure resource. + } + } + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_app_component_get_app_component_request( + test_run_id=test_run_id, + test_id=test_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + +class ServerMetricsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.analytics.loadtestservice.aio.LoadTestClient`'s + :attr:`server_metrics` attribute. + """ + + 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") + + + @overload + async def create_or_update_server_metrics_config( + self, + name: str, + body: JSON, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> JSON: + """Configure server metrics for a test or test run. + + Configure server metrics for a test or test run. + + :param name: Unique name for server metrics, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type name: str + :param body: Server metrics configuration model. Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "metrics": { + "str": { + "aggregation": "str", # Metric aggregation. Required. + "displayDescription": "str", # Optional. Metric description. + "id": "str", # Optional. Unique identifier for metric. + "metricnamespace": "str", # Metric name space. Required. + "name": { + "localizedValue": "str", # Metric localized name. + Required. + "value": "str" # Metric name value. Required. + }, + "resourceId": "str", # Azure resource Id. Required. + "resourceType": "str", # Azure resource type. Required. + "unit": "str" # Optional. Metric unit. + } + }, + "name": "str", # Optional. Server metrics config name. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str" # Optional. [Required, if testId is not given] Load test + run unique identifier. + } + + # response body for status code(s): 200, 201 + response.json() == { + "metrics": { + "str": { + "aggregation": "str", # Metric aggregation. Required. + "displayDescription": "str", # Optional. Metric description. + "id": "str", # Optional. Unique identifier for metric. + "metricnamespace": "str", # Metric name space. Required. + "name": { + "localizedValue": "str", # Metric localized name. + Required. + "value": "str" # Metric name value. Required. + }, + "resourceId": "str", # Azure resource Id. Required. + "resourceType": "str", # Azure resource type. Required. + "unit": "str" # Optional. Metric unit. + } + }, + "name": "str", # Optional. Server metrics config name. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str" # Optional. [Required, if testId is not given] Load test + run unique identifier. + } + """ + + @overload + async def create_or_update_server_metrics_config( + self, + name: str, + body: IO, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> JSON: + """Configure server metrics for a test or test run. + + Configure server metrics for a test or test run. + + :param name: Unique name for server metrics, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type name: str + :param body: Server metrics configuration model. Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 201 + response.json() == { + "metrics": { + "str": { + "aggregation": "str", # Metric aggregation. Required. + "displayDescription": "str", # Optional. Metric description. + "id": "str", # Optional. Unique identifier for metric. + "metricnamespace": "str", # Metric name space. Required. + "name": { + "localizedValue": "str", # Metric localized name. + Required. + "value": "str" # Metric name value. Required. + }, + "resourceId": "str", # Azure resource Id. Required. + "resourceType": "str", # Azure resource type. Required. + "unit": "str" # Optional. Metric unit. + } + }, + "name": "str", # Optional. Server metrics config name. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str" # Optional. [Required, if testId is not given] Load test + run unique identifier. + } + """ + + + @distributed_trace_async + async def create_or_update_server_metrics_config( + self, + name: str, + body: Union[JSON, IO], + **kwargs: Any + ) -> JSON: + """Configure server metrics for a test or test run. + + Configure server metrics for a test or test run. + + :param name: Unique name for server metrics, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type name: str + :param body: Server metrics configuration model. Is either a model type or a IO type. Required. + :type body: JSON or IO + :keyword content_type: Body Parameter content-type. Known values are: + 'application/merge-patch+json'. Default value is None. + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 201 + response.json() == { + "metrics": { + "str": { + "aggregation": "str", # Metric aggregation. Required. + "displayDescription": "str", # Optional. Metric description. + "id": "str", # Optional. Unique identifier for metric. + "metricnamespace": "str", # Metric name space. Required. + "name": { + "localizedValue": "str", # Metric localized name. + Required. + "value": "str" # Metric name value. Required. + }, + "resourceId": "str", # Azure resource Id. Required. + "resourceType": "str", # Azure resource type. Required. + "unit": "str" # Optional. Metric unit. + } + }, + "name": "str", # Optional. Server metrics config name. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str" # Optional. [Required, if testId is not given] Load test + run unique identifier. + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + content_type = content_type or "application/merge-patch+json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = body + + request = build_server_metrics_create_or_update_server_metrics_config_request( + name=name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 201: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace_async + async def get_server_metrics_by_name( + self, + name: str, + **kwargs: Any + ) -> JSON: + """Get server metrics configuration by its name. + + Get server metrics configuration by its name. + + :param name: Unique name for server metrics, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type name: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "metrics": { + "str": { + "aggregation": "str", # Metric aggregation. Required. + "displayDescription": "str", # Optional. Metric description. + "id": "str", # Optional. Unique identifier for metric. + "metricnamespace": "str", # Metric name space. Required. + "name": { + "localizedValue": "str", # Metric localized name. + Required. + "value": "str" # Metric name value. Required. + }, + "resourceId": "str", # Azure resource Id. Required. + "resourceType": "str", # Azure resource type. Required. + "unit": "str" # Optional. Metric unit. + } + }, + "name": "str", # Optional. Server metrics config name. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str" # Optional. [Required, if testId is not given] Load test + run unique identifier. + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_server_metrics_get_server_metrics_by_name_request( + name=name, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace_async + async def delete_server_metrics( # pylint: disable=inconsistent-return-statements + self, + name: str, + **kwargs: Any + ) -> None: + """Delete server metrics configuration by its name. + + Delete server metrics configuration by its name. + + :param name: Unique name for server metrics, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_server_metrics_delete_server_metrics_request( + name=name, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + + + @distributed_trace_async + async def get_server_metrics( + self, + *, + test_run_id: Optional[str] = None, + test_id: Optional[str] = None, + **kwargs: Any + ) -> JSON: + """Get server metrics configuration for a test or test run by its name. + + Get server metrics configuration for a test or test run by its name. + + :keyword test_run_id: [Required, if testId is not provided] Test run Id. Default value is None. + :paramtype test_run_id: str + :keyword test_id: Unique name for load test, must be a valid URL character ^[a-z0-9_-]*$. + Default value is None. + :paramtype test_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "metrics": { + "str": { + "aggregation": "str", # Metric aggregation. Required. + "displayDescription": "str", # Optional. Metric description. + "id": "str", # Optional. Unique identifier for metric. + "metricnamespace": "str", # Metric name space. Required. + "name": { + "localizedValue": "str", # Metric localized name. + Required. + "value": "str" # Metric name value. Required. + }, + "resourceId": "str", # Azure resource Id. Required. + "resourceType": "str", # Azure resource type. Required. + "unit": "str" # Optional. Metric unit. + } + }, + "name": "str", # Optional. Server metrics config name. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str" # Optional. [Required, if testId is not given] Load test + run unique identifier. + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_server_metrics_get_server_metrics_request( + test_run_id=test_run_id, + test_id=test_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace_async + async def get_server_default_metrics( + self, + **kwargs: Any + ) -> JSON: + """Get all default server metrics configuration for supported resource types. + + Get all default server metrics configuration for supported resource types. + + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "defaultMetrics": { + "str": [ + { + "aggregation": "str", # Optional. Default metrics + map {resourceType : list of metrics config} (Refer for metrics + structure: + https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition). + "displayDescription": "str", # Optional. Default + metrics map {resourceType : list of metrics config} (Refer for + metrics structure: + https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition). + "metricnamespace": "str", # Optional. Default + metrics map {resourceType : list of metrics config} (Refer for + metrics structure: + https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition). + "name": { + "localizedValue": "str", # Optional. Default + metrics map {resourceType : list of metrics config} (Refer for + metrics structure: + https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition). + "value": "str" # Optional. Default metrics + map {resourceType : list of metrics config} (Refer for metrics + structure: + https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition). + }, + "unit": "str" # Optional. Default metrics map + {resourceType : list of metrics config} (Refer for metrics structure: + https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition). + } + ] + } + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_server_metrics_get_server_default_metrics_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace_async + async def list_supported_resource_type( + self, + **kwargs: Any + ) -> JSON: + """Get all supported resource types for App Components(Azure resource types). + + Get all supported resource types for App Components(Azure resource types). + + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "value": [ + "str" # Optional. + ] + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_server_metrics_list_supported_resource_type_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + +class TestOperations(abc.ABC): + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.analytics.loadtestservice.aio.LoadTestClient`'s + :attr:`test` attribute. + """ + + 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") + + + @overload + async def create_or_update_test( + self, + test_id: str, + body: JSON, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> JSON: + """Create a new test or Update an existing test. + + Create a new test or Update an existing test. + + :param test_id: Unique name for load test, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type test_id: str + :param body: Load test model. Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "createdBy": "str", # Optional. The user that created the test model. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The created + DateTime(ISO 8601 literal format) of the test model. + "description": "str", # Optional. The test description. + "displayName": "str", # Optional. Display name of a test. + "environmentVariables": { + "str": "str" # Optional. Environment variables which are defined as + a set of pairs. + }, + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + } + }, + "keyvaultReferenceIdentityId": "str", # Optional. Resource Id of the managed + identity referencing the Key vault. + "keyvaultReferenceIdentityType": "str", # Optional. Type of the managed + identity referencing the Key vault. + "lastModifiedBy": "str", # Optional. The user that last modified the test + model. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. The last Modified + DateTime(ISO 8601 literal format) of the test model. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of engine instances to + execute load test. Supported values are in range of 1-45. Required for + creating a new test. + "splitAllCSVs": bool # Optional. Whether all the input CSV files + should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either "u2018stop"u2019 + or "u2018continue"u2019 after the threshold is met. Default is + "u2018continue"u2019. + "actualValue": 0.0, # Optional. The actual value of + the client metric for the test run. + "aggregate": "str", # Optional. The aggregation + function to be applied on the client metric. Allowed functions - + "u2018percentage"u2019 - for error metric , "u2018avg"u2019 - for + response_time_ms and latency metric. + "clientmetric": "str", # Optional. The client metric + on which the criteria should be applied. Allowed values - + "u2018response_time_ms"u2019 , "u2018latency"u2019, + "u2018error"u2019. + "condition": "str", # Optional. The comparison + operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome of the test + run. possible outcome - "u2018passed"u2019 , "u2018failed"u2019 , + "u2018undetermined"u2019. + "value": 0.0 # Optional. The value to compare with + the client metric. Allowed values - "u2018error : [0.0 , 100.0] unit- + % "u2019, response_time_ms and latency : any integer value unit- ms. + } + } + }, + "resourceId": "str", # Optional. Fully qualified resource Id e.g + /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. eg. + AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the secret, of type + AKV_SECRET_URI or SECRET_VALUE. + } + }, + "subnetId": "str", # Optional. Subnet ID on which the load test instances + should run. + "testId": "str" # Optional. Unique test name as identifier. + } + + # response body for status code(s): 200, 201 + response.json() == { + "createdBy": "str", # Optional. The user that created the test model. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The created + DateTime(ISO 8601 literal format) of the test model. + "description": "str", # Optional. The test description. + "displayName": "str", # Optional. Display name of a test. + "environmentVariables": { + "str": "str" # Optional. Environment variables which are defined as + a set of pairs. + }, + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + } + }, + "keyvaultReferenceIdentityId": "str", # Optional. Resource Id of the managed + identity referencing the Key vault. + "keyvaultReferenceIdentityType": "str", # Optional. Type of the managed + identity referencing the Key vault. + "lastModifiedBy": "str", # Optional. The user that last modified the test + model. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. The last Modified + DateTime(ISO 8601 literal format) of the test model. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of engine instances to + execute load test. Supported values are in range of 1-45. Required for + creating a new test. + "splitAllCSVs": bool # Optional. Whether all the input CSV files + should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either "u2018stop"u2019 + or "u2018continue"u2019 after the threshold is met. Default is + "u2018continue"u2019. + "actualValue": 0.0, # Optional. The actual value of + the client metric for the test run. + "aggregate": "str", # Optional. The aggregation + function to be applied on the client metric. Allowed functions - + "u2018percentage"u2019 - for error metric , "u2018avg"u2019 - for + response_time_ms and latency metric. + "clientmetric": "str", # Optional. The client metric + on which the criteria should be applied. Allowed values - + "u2018response_time_ms"u2019 , "u2018latency"u2019, + "u2018error"u2019. + "condition": "str", # Optional. The comparison + operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome of the test + run. possible outcome - "u2018passed"u2019 , "u2018failed"u2019 , + "u2018undetermined"u2019. + "value": 0.0 # Optional. The value to compare with + the client metric. Allowed values - "u2018error : [0.0 , 100.0] unit- + % "u2019, response_time_ms and latency : any integer value unit- ms. + } + } + }, + "resourceId": "str", # Optional. Fully qualified resource Id e.g + /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. eg. + AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the secret, of type + AKV_SECRET_URI or SECRET_VALUE. + } + }, + "subnetId": "str", # Optional. Subnet ID on which the load test instances + should run. + "testId": "str" # Optional. Unique test name as identifier. + } + """ + + @overload + async def create_or_update_test( + self, + test_id: str, + body: IO, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> JSON: + """Create a new test or Update an existing test. + + Create a new test or Update an existing test. + + :param test_id: Unique name for load test, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type test_id: str + :param body: Load test model. Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 201 + response.json() == { + "createdBy": "str", # Optional. The user that created the test model. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The created + DateTime(ISO 8601 literal format) of the test model. + "description": "str", # Optional. The test description. + "displayName": "str", # Optional. Display name of a test. + "environmentVariables": { + "str": "str" # Optional. Environment variables which are defined as + a set of pairs. + }, + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + } + }, + "keyvaultReferenceIdentityId": "str", # Optional. Resource Id of the managed + identity referencing the Key vault. + "keyvaultReferenceIdentityType": "str", # Optional. Type of the managed + identity referencing the Key vault. + "lastModifiedBy": "str", # Optional. The user that last modified the test + model. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. The last Modified + DateTime(ISO 8601 literal format) of the test model. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of engine instances to + execute load test. Supported values are in range of 1-45. Required for + creating a new test. + "splitAllCSVs": bool # Optional. Whether all the input CSV files + should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either "u2018stop"u2019 + or "u2018continue"u2019 after the threshold is met. Default is + "u2018continue"u2019. + "actualValue": 0.0, # Optional. The actual value of + the client metric for the test run. + "aggregate": "str", # Optional. The aggregation + function to be applied on the client metric. Allowed functions - + "u2018percentage"u2019 - for error metric , "u2018avg"u2019 - for + response_time_ms and latency metric. + "clientmetric": "str", # Optional. The client metric + on which the criteria should be applied. Allowed values - + "u2018response_time_ms"u2019 , "u2018latency"u2019, + "u2018error"u2019. + "condition": "str", # Optional. The comparison + operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome of the test + run. possible outcome - "u2018passed"u2019 , "u2018failed"u2019 , + "u2018undetermined"u2019. + "value": 0.0 # Optional. The value to compare with + the client metric. Allowed values - "u2018error : [0.0 , 100.0] unit- + % "u2019, response_time_ms and latency : any integer value unit- ms. + } + } + }, + "resourceId": "str", # Optional. Fully qualified resource Id e.g + /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. eg. + AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the secret, of type + AKV_SECRET_URI or SECRET_VALUE. + } + }, + "subnetId": "str", # Optional. Subnet ID on which the load test instances + should run. + "testId": "str" # Optional. Unique test name as identifier. + } + """ + + + @distributed_trace_async + async def create_or_update_test( + self, + test_id: str, + body: Union[JSON, IO], + **kwargs: Any + ) -> JSON: + """Create a new test or Update an existing test. + + Create a new test or Update an existing test. + + :param test_id: Unique name for load test, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type test_id: str + :param body: Load test model. Is either a model type or a IO type. Required. + :type body: JSON or IO + :keyword content_type: Body Parameter content-type. Known values are: + 'application/merge-patch+json'. Default value is None. + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 201 + response.json() == { + "createdBy": "str", # Optional. The user that created the test model. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The created + DateTime(ISO 8601 literal format) of the test model. + "description": "str", # Optional. The test description. + "displayName": "str", # Optional. Display name of a test. + "environmentVariables": { + "str": "str" # Optional. Environment variables which are defined as + a set of pairs. + }, + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + } + }, + "keyvaultReferenceIdentityId": "str", # Optional. Resource Id of the managed + identity referencing the Key vault. + "keyvaultReferenceIdentityType": "str", # Optional. Type of the managed + identity referencing the Key vault. + "lastModifiedBy": "str", # Optional. The user that last modified the test + model. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. The last Modified + DateTime(ISO 8601 literal format) of the test model. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of engine instances to + execute load test. Supported values are in range of 1-45. Required for + creating a new test. + "splitAllCSVs": bool # Optional. Whether all the input CSV files + should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either "u2018stop"u2019 + or "u2018continue"u2019 after the threshold is met. Default is + "u2018continue"u2019. + "actualValue": 0.0, # Optional. The actual value of + the client metric for the test run. + "aggregate": "str", # Optional. The aggregation + function to be applied on the client metric. Allowed functions - + "u2018percentage"u2019 - for error metric , "u2018avg"u2019 - for + response_time_ms and latency metric. + "clientmetric": "str", # Optional. The client metric + on which the criteria should be applied. Allowed values - + "u2018response_time_ms"u2019 , "u2018latency"u2019, + "u2018error"u2019. + "condition": "str", # Optional. The comparison + operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome of the test + run. possible outcome - "u2018passed"u2019 , "u2018failed"u2019 , + "u2018undetermined"u2019. + "value": 0.0 # Optional. The value to compare with + the client metric. Allowed values - "u2018error : [0.0 , 100.0] unit- + % "u2019, response_time_ms and latency : any integer value unit- ms. + } + } + }, + "resourceId": "str", # Optional. Fully qualified resource Id e.g + /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. eg. + AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the secret, of type + AKV_SECRET_URI or SECRET_VALUE. + } + }, + "subnetId": "str", # Optional. Subnet ID on which the load test instances + should run. + "testId": "str" # Optional. Unique test name as identifier. + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + content_type = content_type or "application/merge-patch+json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = body + + request = build_test_create_or_update_test_request( + test_id=test_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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 201: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace_async + async def delete_load_test( # pylint: disable=inconsistent-return-statements + self, + test_id: str, + **kwargs: Any + ) -> None: + """Delete a test by its name. + + Delete a test by its name. + + :param test_id: Unique name for load test, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type test_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_test_delete_load_test_request( + test_id=test_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + + + @distributed_trace_async + async def get_load_test( + self, + test_id: str, + **kwargs: Any + ) -> JSON: + """Get load test details by test name. + + Get load test details by test name. + + :param test_id: Unique name for load test, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type test_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "createdBy": "str", # Optional. The user that created the test model. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The created + DateTime(ISO 8601 literal format) of the test model. + "description": "str", # Optional. The test description. + "displayName": "str", # Optional. Display name of a test. + "environmentVariables": { + "str": "str" # Optional. Environment variables which are defined as + a set of pairs. + }, + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + } + }, + "keyvaultReferenceIdentityId": "str", # Optional. Resource Id of the managed + identity referencing the Key vault. + "keyvaultReferenceIdentityType": "str", # Optional. Type of the managed + identity referencing the Key vault. + "lastModifiedBy": "str", # Optional. The user that last modified the test + model. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. The last Modified + DateTime(ISO 8601 literal format) of the test model. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of engine instances to + execute load test. Supported values are in range of 1-45. Required for + creating a new test. + "splitAllCSVs": bool # Optional. Whether all the input CSV files + should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either "u2018stop"u2019 + or "u2018continue"u2019 after the threshold is met. Default is + "u2018continue"u2019. + "actualValue": 0.0, # Optional. The actual value of + the client metric for the test run. + "aggregate": "str", # Optional. The aggregation + function to be applied on the client metric. Allowed functions - + "u2018percentage"u2019 - for error metric , "u2018avg"u2019 - for + response_time_ms and latency metric. + "clientmetric": "str", # Optional. The client metric + on which the criteria should be applied. Allowed values - + "u2018response_time_ms"u2019 , "u2018latency"u2019, + "u2018error"u2019. + "condition": "str", # Optional. The comparison + operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome of the test + run. possible outcome - "u2018passed"u2019 , "u2018failed"u2019 , + "u2018undetermined"u2019. + "value": 0.0 # Optional. The value to compare with + the client metric. Allowed values - "u2018error : [0.0 , 100.0] unit- + % "u2019, response_time_ms and latency : any integer value unit- ms. + } + } + }, + "resourceId": "str", # Optional. Fully qualified resource Id e.g + /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. eg. + AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the secret, of type + AKV_SECRET_URI or SECRET_VALUE. + } + }, + "subnetId": "str", # Optional. Subnet ID on which the load test instances + should run. + "testId": "str" # Optional. Unique test name as identifier. + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_test_get_load_test_request( + test_id=test_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace_async + async def list_load_test_search( + self, + *, + order_by: Optional[str] = None, + search: Optional[str] = None, + last_updated_start_time: Optional[datetime.datetime] = None, + last_updated_end_time: Optional[datetime.datetime] = None, + continuation_token_parameter: Optional[str] = None, + max_page_size: int = 50, + **kwargs: Any + ) -> JSON: + """Get all load tests by the fully qualified resource Id e.g + subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + + Get all load tests by the fully qualified resource Id e.g + subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + + :keyword order_by: Sort on one of the field - lastModifiedDateTime, displayName, createdBy in + (field asc/desc) format. eg: displayName asc. Default value is None. + :paramtype order_by: str + :keyword search: Filter search based on searchable fields - testId, createdBy. Default value is + None. + :paramtype search: str + :keyword last_updated_start_time: Start DateTime(ISO 8601 literal format) of the last updated + time range to filter tests. Default value is None. + :paramtype last_updated_start_time: ~datetime.datetime + :keyword last_updated_end_time: End DateTime(ISO 8601 literal format) of the last updated time + range to filter tests. Default value is None. + :paramtype last_updated_end_time: ~datetime.datetime + :keyword continuation_token_parameter: Continuation token to get the next page of response. + Default value is None. + :paramtype continuation_token_parameter: str + :keyword max_page_size: Number of results in response. Default value is 50. + :paramtype max_page_size: int + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str", # Optional. Link for the next list of resources in case + of paginated results, if applicable. + "value": [ + { + "createdBy": "str", # Optional. The user that created the + test model. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The + created DateTime(ISO 8601 literal format) of the test model. + "description": "str", # Optional. The test description. + "displayName": "str", # Optional. Display name of a test. + "environmentVariables": { + "str": "str" # Optional. Environment variables which + are defined as a set of pairs. + }, + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", + # Optional. Expiry time of the file. + "fileId": "str", # Optional. File + unique identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: + 0, 1, and 2. + "filename": "str", # Optional. Name + of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # + Optional. Validation status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # + Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique + identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, + 1, and 2. + "filename": "str", # Optional. Name of the + file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. + Validation status of the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # + Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique + identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, + 1, and 2. + "filename": "str", # Optional. Name of the + file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. + Validation status of the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # + Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique + identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, + 1, and 2. + "filename": "str", # Optional. Name of the + file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. + Validation status of the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # + Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique + identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, + 1, and 2. + "filename": "str", # Optional. Name of the + file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. + Validation status of the file. + } + }, + "keyvaultReferenceIdentityId": "str", # Optional. Resource + Id of the managed identity referencing the Key vault. + "keyvaultReferenceIdentityType": "str", # Optional. Type of + the managed identity referencing the Key vault. + "lastModifiedBy": "str", # Optional. The user that last + modified the test model. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. + The last Modified DateTime(ISO 8601 literal format) of the test model. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of + engine instances to execute load test. Supported values are in range + of 1-45. Required for creating a new test. + "splitAllCSVs": bool # Optional. Whether all the + input CSV files should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either + "u2018stop"u2019 or "u2018continue"u2019 after the threshold + is met. Default is "u2018continue"u2019. + "actualValue": 0.0, # Optional. The + actual value of the client metric for the test run. + "aggregate": "str", # Optional. The + aggregation function to be applied on the client metric. + Allowed functions - "u2018percentage"u2019 - for error metric + , "u2018avg"u2019 - for response_time_ms and latency metric. + "clientmetric": "str", # Optional. + The client metric on which the criteria should be applied. + Allowed values - "u2018response_time_ms"u2019 , + "u2018latency"u2019, "u2018error"u2019. + "condition": "str", # Optional. The + comparison operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome + of the test run. possible outcome - "u2018passed"u2019 , + "u2018failed"u2019 , "u2018undetermined"u2019. + "value": 0.0 # Optional. The value + to compare with the client metric. Allowed values - + "u2018error : [0.0 , 100.0] unit- % "u2019, response_time_ms + and latency : any integer value unit- ms. + } + } + }, + "resourceId": "str", # Optional. Fully qualified resource Id + e.g + /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. + eg. AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the + secret, of type AKV_SECRET_URI or SECRET_VALUE. + } + }, + "subnetId": "str", # Optional. Subnet ID on which the load + test instances should run. + "testId": "str" # Optional. Unique test name as identifier. + } + ] + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_test_list_load_test_search_request( + order_by=order_by, + search=search, + last_updated_start_time=last_updated_start_time, + last_updated_end_time=last_updated_end_time, + continuation_token_parameter=continuation_token_parameter, + max_page_size=max_page_size, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace_async + @abc.abstractmethod + async def upload_test_file( + self, + *args, + **kwargs + ) -> JSON: + """You need to write a custom operation for "upload_test_file". Please refer to + https://aka.ms/azsdk/python/dpcodegen/python/customize to learn how to customize. + + + Example: + .. code-block:: python + + # response body for status code(s): 201 + response.json() == { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the file type (0 = + JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, 1, + and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of the file. + } + """ + + + @distributed_trace_async + async def get_test_file( + self, + test_id: str, + file_id: str, + **kwargs: Any + ) -> JSON: + """Get test file by the file name. + + Get test file by the file name. + + :param test_id: Unique name for load test, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type test_id: str + :param file_id: Unique identifier for test file, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type file_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the file type (0 = + JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, 1, + and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of the file. + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_test_get_test_file_request( + test_id=test_id, + file_id=file_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace_async + async def delete_test_file( # pylint: disable=inconsistent-return-statements + self, + test_id: str, + file_id: str, + **kwargs: Any + ) -> None: + """Delete file by the file name for a test. + + Delete file by the file name for a test. + + :param test_id: Unique name for load test, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type test_id: str + :param file_id: Unique identifier for test file, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type file_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_test_delete_test_file_request( + test_id=test_id, + file_id=file_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + + + @distributed_trace_async + async def get_all_test_files( + self, + test_id: str, + *, + continuation_token_parameter: Optional[str] = None, + **kwargs: Any + ) -> JSON: + """Get all test files. + + Get all test files. + + :param test_id: Unique name for load test, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type test_id: str + :keyword continuation_token_parameter: Continuation token to get the next page of response. + Default value is None. + :paramtype continuation_token_parameter: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str", # Optional. Link for the next list of file URLs, if + applicable. + "value": [ + { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + } + ] + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_test_get_all_test_files_request( + test_id=test_id, + continuation_token_parameter=continuation_token_parameter, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + +class TestRunOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.analytics.loadtestservice.aio.LoadTestClient`'s + :attr:`test_run` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def delete_test_run( # pylint: disable=inconsistent-return-statements + self, + test_run_id: str, + **kwargs: Any + ) -> None: + """Delete a test run by its name. + + Delete a test run by its name. + + :param test_run_id: Unique name of the load test run, must be a valid URL character + ^[a-z0-9_-]*$. Required. + :type test_run_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_test_run_delete_test_run_request( + test_run_id=test_run_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + + + @overload + async def create_and_update_test( + self, + test_run_id: str, + body: JSON, + *, + old_test_run_id: Optional[str] = None, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> JSON: + """Create and start a new test run with the given name. + + Create and start a new test run with the given name. + + :param test_run_id: Unique name of the load test run, must be a valid URL character + ^[a-z0-9_-]*$. Required. + :type test_run_id: str + :param body: Load test run model. Required. + :type body: JSON + :keyword old_test_run_id: Existing test run Id that should be rerun. Default value is None. + :paramtype old_test_run_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "createdBy": "str", # Optional. The user that created the test run. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The created + DateTime(ISO 8601 literal format) of the test run. + "description": "str", # Optional. The test run description. + "displayName": "str", # Optional. Display name of a test run. + "duration": 0, # Optional. Test run duration in milliseconds. + "endDateTime": "2020-02-20 00:00:00", # Optional. The test run end + DateTime(ISO 8601 literal format). + "environmentVariables": { + "str": "str" # Optional. Environment variables which are defined as + a set of pairs. + }, + "executedDateTime": "2020-02-20 00:00:00", # Optional. Test run initiated + time. + "lastModifiedBy": "str", # Optional. The user that updated the test run. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. The last updated + DateTime(ISO 8601 literal format) of the test run. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of engine instances to + execute load test. Supported values are in range of 1-45. Required for + creating a new test. + "splitAllCSVs": bool # Optional. Whether all the input CSV files + should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either "u2018stop"u2019 + or "u2018continue"u2019 after the threshold is met. Default is + "u2018continue"u2019. + "actualValue": 0.0, # Optional. The actual value of + the client metric for the test run. + "aggregate": "str", # Optional. The aggregation + function to be applied on the client metric. Allowed functions - + "u2018percentage"u2019 - for error metric , "u2018avg"u2019 - for + response_time_ms and latency metric. + "clientmetric": "str", # Optional. The client metric + on which the criteria should be applied. Allowed values - + "u2018response_time_ms"u2019 , "u2018latency"u2019, + "u2018error"u2019. + "condition": "str", # Optional. The comparison + operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome of the test + run. possible outcome - "u2018passed"u2019 , "u2018failed"u2019 , + "u2018undetermined"u2019. + "value": 0.0 # Optional. The value to compare with + the client metric. Allowed values - "u2018error : [0.0 , 100.0] unit- + % "u2019, response_time_ms and latency : any integer value unit- ms. + } + } + }, + "portalUrl": "str", # Optional. Portal url. + "resourceId": "str", # Optional. Load test resource Id. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. eg. + AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the secret, of type + AKV_SECRET_URI or SECRET_VALUE. + } + }, + "startDateTime": "2020-02-20 00:00:00", # Optional. The test run start + DateTime(ISO 8601 literal format). + "status": "str", # Optional. The test run status. + "subnetId": "str", # Optional. Subnet ID on which the load test instances + should run. + "testArtifacts": { + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", # + Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique + identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, + 1, and 2. + "filename": "str", # Optional. Name of the + file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. + Validation status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + }, + "outputArtifacts": { + "logsUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "resultUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + } + }, + "testId": "str", # Optional. Associated test Id. + "testResult": "str", # Optional. Test result for pass/Fail criteria used + during the test run. possible outcome - "u2018Passed"u2019 , "u2018Failed"u2019 , + "u2018Not Applicable"u2019. + "testRunId": "str", # Optional. Unique test run name as identifier. + "testRunStatistics": { + "str": { + "errorCount": 0.0, # Optional. Error count. + "errorPct": 0.0, # Optional. Error percentage. + "maxResTime": 0.0, # Optional. Max response time. + "meanResTime": 0.0, # Optional. Mean response time. + "medianResTime": 0.0, # Optional. Median response time. + "minResTime": 0.0, # Optional. Minimum response time. + "pct1ResTime": 0.0, # Optional. 90 percentile response time. + "pct2ResTime": 0.0, # Optional. 95 percentile response time. + "pct3ResTime": 0.0, # Optional. 99 percentile response time. + "receivedKBytesPerSec": 0.0, # Optional. Received network + bytes. + "sampleCount": 0.0, # Optional. Sampler count. + "sentKBytesPerSec": 0.0, # Optional. Sent network bytes. + "throughput": 0.0, # Optional. Throughput. + "transaction": "str" # Optional. Transaction name. + } + }, + "vusers": 0 # Optional. Number of virtual users, for which test has been + run. + } + + # response body for status code(s): 200 + response.json() == { + "createdBy": "str", # Optional. The user that created the test run. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The created + DateTime(ISO 8601 literal format) of the test run. + "description": "str", # Optional. The test run description. + "displayName": "str", # Optional. Display name of a test run. + "duration": 0, # Optional. Test run duration in milliseconds. + "endDateTime": "2020-02-20 00:00:00", # Optional. The test run end + DateTime(ISO 8601 literal format). + "environmentVariables": { + "str": "str" # Optional. Environment variables which are defined as + a set of pairs. + }, + "executedDateTime": "2020-02-20 00:00:00", # Optional. Test run initiated + time. + "lastModifiedBy": "str", # Optional. The user that updated the test run. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. The last updated + DateTime(ISO 8601 literal format) of the test run. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of engine instances to + execute load test. Supported values are in range of 1-45. Required for + creating a new test. + "splitAllCSVs": bool # Optional. Whether all the input CSV files + should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either "u2018stop"u2019 + or "u2018continue"u2019 after the threshold is met. Default is + "u2018continue"u2019. + "actualValue": 0.0, # Optional. The actual value of + the client metric for the test run. + "aggregate": "str", # Optional. The aggregation + function to be applied on the client metric. Allowed functions - + "u2018percentage"u2019 - for error metric , "u2018avg"u2019 - for + response_time_ms and latency metric. + "clientmetric": "str", # Optional. The client metric + on which the criteria should be applied. Allowed values - + "u2018response_time_ms"u2019 , "u2018latency"u2019, + "u2018error"u2019. + "condition": "str", # Optional. The comparison + operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome of the test + run. possible outcome - "u2018passed"u2019 , "u2018failed"u2019 , + "u2018undetermined"u2019. + "value": 0.0 # Optional. The value to compare with + the client metric. Allowed values - "u2018error : [0.0 , 100.0] unit- + % "u2019, response_time_ms and latency : any integer value unit- ms. + } + } + }, + "portalUrl": "str", # Optional. Portal url. + "resourceId": "str", # Optional. Load test resource Id. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. eg. + AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the secret, of type + AKV_SECRET_URI or SECRET_VALUE. + } + }, + "startDateTime": "2020-02-20 00:00:00", # Optional. The test run start + DateTime(ISO 8601 literal format). + "status": "str", # Optional. The test run status. + "subnetId": "str", # Optional. Subnet ID on which the load test instances + should run. + "testArtifacts": { + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", # + Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique + identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, + 1, and 2. + "filename": "str", # Optional. Name of the + file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. + Validation status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + }, + "outputArtifacts": { + "logsUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "resultUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + } + }, + "testId": "str", # Optional. Associated test Id. + "testResult": "str", # Optional. Test result for pass/Fail criteria used + during the test run. possible outcome - "u2018Passed"u2019 , "u2018Failed"u2019 , + "u2018Not Applicable"u2019. + "testRunId": "str", # Optional. Unique test run name as identifier. + "testRunStatistics": { + "str": { + "errorCount": 0.0, # Optional. Error count. + "errorPct": 0.0, # Optional. Error percentage. + "maxResTime": 0.0, # Optional. Max response time. + "meanResTime": 0.0, # Optional. Mean response time. + "medianResTime": 0.0, # Optional. Median response time. + "minResTime": 0.0, # Optional. Minimum response time. + "pct1ResTime": 0.0, # Optional. 90 percentile response time. + "pct2ResTime": 0.0, # Optional. 95 percentile response time. + "pct3ResTime": 0.0, # Optional. 99 percentile response time. + "receivedKBytesPerSec": 0.0, # Optional. Received network + bytes. + "sampleCount": 0.0, # Optional. Sampler count. + "sentKBytesPerSec": 0.0, # Optional. Sent network bytes. + "throughput": 0.0, # Optional. Throughput. + "transaction": "str" # Optional. Transaction name. + } + }, + "vusers": 0 # Optional. Number of virtual users, for which test has been + run. + } + """ + + @overload + async def create_and_update_test( + self, + test_run_id: str, + body: IO, + *, + old_test_run_id: Optional[str] = None, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> JSON: + """Create and start a new test run with the given name. + + Create and start a new test run with the given name. + + :param test_run_id: Unique name of the load test run, must be a valid URL character + ^[a-z0-9_-]*$. Required. + :type test_run_id: str + :param body: Load test run model. Required. + :type body: IO + :keyword old_test_run_id: Existing test run Id that should be rerun. Default value is None. + :paramtype old_test_run_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "createdBy": "str", # Optional. The user that created the test run. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The created + DateTime(ISO 8601 literal format) of the test run. + "description": "str", # Optional. The test run description. + "displayName": "str", # Optional. Display name of a test run. + "duration": 0, # Optional. Test run duration in milliseconds. + "endDateTime": "2020-02-20 00:00:00", # Optional. The test run end + DateTime(ISO 8601 literal format). + "environmentVariables": { + "str": "str" # Optional. Environment variables which are defined as + a set of pairs. + }, + "executedDateTime": "2020-02-20 00:00:00", # Optional. Test run initiated + time. + "lastModifiedBy": "str", # Optional. The user that updated the test run. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. The last updated + DateTime(ISO 8601 literal format) of the test run. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of engine instances to + execute load test. Supported values are in range of 1-45. Required for + creating a new test. + "splitAllCSVs": bool # Optional. Whether all the input CSV files + should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either "u2018stop"u2019 + or "u2018continue"u2019 after the threshold is met. Default is + "u2018continue"u2019. + "actualValue": 0.0, # Optional. The actual value of + the client metric for the test run. + "aggregate": "str", # Optional. The aggregation + function to be applied on the client metric. Allowed functions - + "u2018percentage"u2019 - for error metric , "u2018avg"u2019 - for + response_time_ms and latency metric. + "clientmetric": "str", # Optional. The client metric + on which the criteria should be applied. Allowed values - + "u2018response_time_ms"u2019 , "u2018latency"u2019, + "u2018error"u2019. + "condition": "str", # Optional. The comparison + operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome of the test + run. possible outcome - "u2018passed"u2019 , "u2018failed"u2019 , + "u2018undetermined"u2019. + "value": 0.0 # Optional. The value to compare with + the client metric. Allowed values - "u2018error : [0.0 , 100.0] unit- + % "u2019, response_time_ms and latency : any integer value unit- ms. + } + } + }, + "portalUrl": "str", # Optional. Portal url. + "resourceId": "str", # Optional. Load test resource Id. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. eg. + AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the secret, of type + AKV_SECRET_URI or SECRET_VALUE. + } + }, + "startDateTime": "2020-02-20 00:00:00", # Optional. The test run start + DateTime(ISO 8601 literal format). + "status": "str", # Optional. The test run status. + "subnetId": "str", # Optional. Subnet ID on which the load test instances + should run. + "testArtifacts": { + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", # + Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique + identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, + 1, and 2. + "filename": "str", # Optional. Name of the + file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. + Validation status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + }, + "outputArtifacts": { + "logsUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "resultUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + } + }, + "testId": "str", # Optional. Associated test Id. + "testResult": "str", # Optional. Test result for pass/Fail criteria used + during the test run. possible outcome - "u2018Passed"u2019 , "u2018Failed"u2019 , + "u2018Not Applicable"u2019. + "testRunId": "str", # Optional. Unique test run name as identifier. + "testRunStatistics": { + "str": { + "errorCount": 0.0, # Optional. Error count. + "errorPct": 0.0, # Optional. Error percentage. + "maxResTime": 0.0, # Optional. Max response time. + "meanResTime": 0.0, # Optional. Mean response time. + "medianResTime": 0.0, # Optional. Median response time. + "minResTime": 0.0, # Optional. Minimum response time. + "pct1ResTime": 0.0, # Optional. 90 percentile response time. + "pct2ResTime": 0.0, # Optional. 95 percentile response time. + "pct3ResTime": 0.0, # Optional. 99 percentile response time. + "receivedKBytesPerSec": 0.0, # Optional. Received network + bytes. + "sampleCount": 0.0, # Optional. Sampler count. + "sentKBytesPerSec": 0.0, # Optional. Sent network bytes. + "throughput": 0.0, # Optional. Throughput. + "transaction": "str" # Optional. Transaction name. + } + }, + "vusers": 0 # Optional. Number of virtual users, for which test has been + run. + } + """ + + + @distributed_trace_async + async def create_and_update_test( + self, + test_run_id: str, + body: Union[JSON, IO], + *, + old_test_run_id: Optional[str] = None, + **kwargs: Any + ) -> JSON: + """Create and start a new test run with the given name. + + Create and start a new test run with the given name. + + :param test_run_id: Unique name of the load test run, must be a valid URL character + ^[a-z0-9_-]*$. Required. + :type test_run_id: str + :param body: Load test run model. Is either a model type or a IO type. Required. + :type body: JSON or IO + :keyword old_test_run_id: Existing test run Id that should be rerun. Default value is None. + :paramtype old_test_run_id: str + :keyword content_type: Body Parameter content-type. Known values are: + 'application/merge-patch+json'. Default value is None. + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "createdBy": "str", # Optional. The user that created the test run. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The created + DateTime(ISO 8601 literal format) of the test run. + "description": "str", # Optional. The test run description. + "displayName": "str", # Optional. Display name of a test run. + "duration": 0, # Optional. Test run duration in milliseconds. + "endDateTime": "2020-02-20 00:00:00", # Optional. The test run end + DateTime(ISO 8601 literal format). + "environmentVariables": { + "str": "str" # Optional. Environment variables which are defined as + a set of pairs. + }, + "executedDateTime": "2020-02-20 00:00:00", # Optional. Test run initiated + time. + "lastModifiedBy": "str", # Optional. The user that updated the test run. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. The last updated + DateTime(ISO 8601 literal format) of the test run. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of engine instances to + execute load test. Supported values are in range of 1-45. Required for + creating a new test. + "splitAllCSVs": bool # Optional. Whether all the input CSV files + should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either "u2018stop"u2019 + or "u2018continue"u2019 after the threshold is met. Default is + "u2018continue"u2019. + "actualValue": 0.0, # Optional. The actual value of + the client metric for the test run. + "aggregate": "str", # Optional. The aggregation + function to be applied on the client metric. Allowed functions - + "u2018percentage"u2019 - for error metric , "u2018avg"u2019 - for + response_time_ms and latency metric. + "clientmetric": "str", # Optional. The client metric + on which the criteria should be applied. Allowed values - + "u2018response_time_ms"u2019 , "u2018latency"u2019, + "u2018error"u2019. + "condition": "str", # Optional. The comparison + operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome of the test + run. possible outcome - "u2018passed"u2019 , "u2018failed"u2019 , + "u2018undetermined"u2019. + "value": 0.0 # Optional. The value to compare with + the client metric. Allowed values - "u2018error : [0.0 , 100.0] unit- + % "u2019, response_time_ms and latency : any integer value unit- ms. + } + } + }, + "portalUrl": "str", # Optional. Portal url. + "resourceId": "str", # Optional. Load test resource Id. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. eg. + AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the secret, of type + AKV_SECRET_URI or SECRET_VALUE. + } + }, + "startDateTime": "2020-02-20 00:00:00", # Optional. The test run start + DateTime(ISO 8601 literal format). + "status": "str", # Optional. The test run status. + "subnetId": "str", # Optional. Subnet ID on which the load test instances + should run. + "testArtifacts": { + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", # + Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique + identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, + 1, and 2. + "filename": "str", # Optional. Name of the + file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. + Validation status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + }, + "outputArtifacts": { + "logsUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "resultUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + } + }, + "testId": "str", # Optional. Associated test Id. + "testResult": "str", # Optional. Test result for pass/Fail criteria used + during the test run. possible outcome - "u2018Passed"u2019 , "u2018Failed"u2019 , + "u2018Not Applicable"u2019. + "testRunId": "str", # Optional. Unique test run name as identifier. + "testRunStatistics": { + "str": { + "errorCount": 0.0, # Optional. Error count. + "errorPct": 0.0, # Optional. Error percentage. + "maxResTime": 0.0, # Optional. Max response time. + "meanResTime": 0.0, # Optional. Mean response time. + "medianResTime": 0.0, # Optional. Median response time. + "minResTime": 0.0, # Optional. Minimum response time. + "pct1ResTime": 0.0, # Optional. 90 percentile response time. + "pct2ResTime": 0.0, # Optional. 95 percentile response time. + "pct3ResTime": 0.0, # Optional. 99 percentile response time. + "receivedKBytesPerSec": 0.0, # Optional. Received network + bytes. + "sampleCount": 0.0, # Optional. Sampler count. + "sentKBytesPerSec": 0.0, # Optional. Sent network bytes. + "throughput": 0.0, # Optional. Throughput. + "transaction": "str" # Optional. Transaction name. + } + }, + "vusers": 0 # Optional. Number of virtual users, for which test has been + run. + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + content_type = content_type or "application/merge-patch+json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = body + + request = build_test_run_create_and_update_test_request( + test_run_id=test_run_id, + old_test_run_id=old_test_run_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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace_async + async def get_test_run( + self, + test_run_id: str, + **kwargs: Any + ) -> JSON: + """Get test run details by name. + + Get test run details by name. + + :param test_run_id: Unique name of load test run, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type test_run_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "createdBy": "str", # Optional. The user that created the test run. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The created + DateTime(ISO 8601 literal format) of the test run. + "description": "str", # Optional. The test run description. + "displayName": "str", # Optional. Display name of a test run. + "duration": 0, # Optional. Test run duration in milliseconds. + "endDateTime": "2020-02-20 00:00:00", # Optional. The test run end + DateTime(ISO 8601 literal format). + "environmentVariables": { + "str": "str" # Optional. Environment variables which are defined as + a set of pairs. + }, + "executedDateTime": "2020-02-20 00:00:00", # Optional. Test run initiated + time. + "lastModifiedBy": "str", # Optional. The user that updated the test run. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. The last updated + DateTime(ISO 8601 literal format) of the test run. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of engine instances to + execute load test. Supported values are in range of 1-45. Required for + creating a new test. + "splitAllCSVs": bool # Optional. Whether all the input CSV files + should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either "u2018stop"u2019 + or "u2018continue"u2019 after the threshold is met. Default is + "u2018continue"u2019. + "actualValue": 0.0, # Optional. The actual value of + the client metric for the test run. + "aggregate": "str", # Optional. The aggregation + function to be applied on the client metric. Allowed functions - + "u2018percentage"u2019 - for error metric , "u2018avg"u2019 - for + response_time_ms and latency metric. + "clientmetric": "str", # Optional. The client metric + on which the criteria should be applied. Allowed values - + "u2018response_time_ms"u2019 , "u2018latency"u2019, + "u2018error"u2019. + "condition": "str", # Optional. The comparison + operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome of the test + run. possible outcome - "u2018passed"u2019 , "u2018failed"u2019 , + "u2018undetermined"u2019. + "value": 0.0 # Optional. The value to compare with + the client metric. Allowed values - "u2018error : [0.0 , 100.0] unit- + % "u2019, response_time_ms and latency : any integer value unit- ms. + } + } + }, + "portalUrl": "str", # Optional. Portal url. + "resourceId": "str", # Optional. Load test resource Id. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. eg. + AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the secret, of type + AKV_SECRET_URI or SECRET_VALUE. + } + }, + "startDateTime": "2020-02-20 00:00:00", # Optional. The test run start + DateTime(ISO 8601 literal format). + "status": "str", # Optional. The test run status. + "subnetId": "str", # Optional. Subnet ID on which the load test instances + should run. + "testArtifacts": { + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", # + Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique + identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, + 1, and 2. + "filename": "str", # Optional. Name of the + file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. + Validation status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + }, + "outputArtifacts": { + "logsUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "resultUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + } + }, + "testId": "str", # Optional. Associated test Id. + "testResult": "str", # Optional. Test result for pass/Fail criteria used + during the test run. possible outcome - "u2018Passed"u2019 , "u2018Failed"u2019 , + "u2018Not Applicable"u2019. + "testRunId": "str", # Optional. Unique test run name as identifier. + "testRunStatistics": { + "str": { + "errorCount": 0.0, # Optional. Error count. + "errorPct": 0.0, # Optional. Error percentage. + "maxResTime": 0.0, # Optional. Max response time. + "meanResTime": 0.0, # Optional. Mean response time. + "medianResTime": 0.0, # Optional. Median response time. + "minResTime": 0.0, # Optional. Minimum response time. + "pct1ResTime": 0.0, # Optional. 90 percentile response time. + "pct2ResTime": 0.0, # Optional. 95 percentile response time. + "pct3ResTime": 0.0, # Optional. 99 percentile response time. + "receivedKBytesPerSec": 0.0, # Optional. Received network + bytes. + "sampleCount": 0.0, # Optional. Sampler count. + "sentKBytesPerSec": 0.0, # Optional. Sent network bytes. + "throughput": 0.0, # Optional. Throughput. + "transaction": "str" # Optional. Transaction name. + } + }, + "vusers": 0 # Optional. Number of virtual users, for which test has been + run. + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_test_run_get_test_run_request( + test_run_id=test_run_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace_async + async def get_test_run_file( + self, + test_run_id: str, + file_id: str, + **kwargs: Any + ) -> JSON: + """Get test run file by file name. + + Get test run file by file name. + + :param test_run_id: Unique name of load test run, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type test_run_id: str + :param file_id: Unique identifier for test run file, must be a valid URL character + ^[a-z0-9_-]*$. Required. + :type file_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the file type (0 = + JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, 1, + and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of the file. + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_test_run_get_test_run_file_request( + test_run_id=test_run_id, + file_id=file_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace_async + async def list_test_runs_search( + self, + *, + order_by: Optional[str] = None, + continuation_token_parameter: Optional[str] = None, + search: Optional[str] = None, + execution_from: Optional[datetime.datetime] = None, + execution_to: Optional[datetime.datetime] = None, + status: Optional[str] = None, + max_page_size: int = 50, + test_id: Optional[str] = None, + **kwargs: Any + ) -> JSON: + """Get all test runs with given filters. + + Get all test runs with given filters. + + :keyword order_by: Sort on one of the field - status, displayName, executedDateTime in (field + asc/desc) format. eg: displayName asc. Default value is None. + :paramtype order_by: str + :keyword continuation_token_parameter: Continuation token to get the next page of response. + Default value is None. + :paramtype continuation_token_parameter: str + :keyword search: Filter search based on searchable fields - description, executedUser. Default + value is None. + :paramtype search: str + :keyword execution_from: The end DateTime(ISO 8601 literal format) of test-run execution time + filter range. Default value is None. + :paramtype execution_from: ~datetime.datetime + :keyword execution_to: The start DateTime(ISO 8601 literal format) of test-run execution time + filter range. Default value is None. + :paramtype execution_to: ~datetime.datetime + :keyword status: Comma separated list of test run status, value can be - "ACCEPTED", + "NOTSTARTED","PROVISIONING","PROVISIONED","CONFIGURING", + "CONFIGURED","EXECUTING","EXECUTED","DEPROVISIONING","DEPROVISIONED","DONE","CANCELLED","FAILED". + Default value is None. + :paramtype status: str + :keyword max_page_size: Number of results in response. Default value is 50. + :paramtype max_page_size: int + :keyword test_id: Unique name for load test, must be a valid URL character ^[a-z0-9_-]*$. + Default value is None. + :paramtype test_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str", # Optional. Link for the next list of resources in case + of paginated results, if applicable. + "value": [ + { + "createdBy": "str", # Optional. The user that created the + test run. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The + created DateTime(ISO 8601 literal format) of the test run. + "description": "str", # Optional. The test run description. + "displayName": "str", # Optional. Display name of a test + run. + "duration": 0, # Optional. Test run duration in + milliseconds. + "endDateTime": "2020-02-20 00:00:00", # Optional. The test + run end DateTime(ISO 8601 literal format). + "environmentVariables": { + "str": "str" # Optional. Environment variables which + are defined as a set of pairs. + }, + "executedDateTime": "2020-02-20 00:00:00", # Optional. Test + run initiated time. + "lastModifiedBy": "str", # Optional. The user that updated + the test run. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. + The last updated DateTime(ISO 8601 literal format) of the test run. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of + engine instances to execute load test. Supported values are in range + of 1-45. Required for creating a new test. + "splitAllCSVs": bool # Optional. Whether all the + input CSV files should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either + "u2018stop"u2019 or "u2018continue"u2019 after the threshold + is met. Default is "u2018continue"u2019. + "actualValue": 0.0, # Optional. The + actual value of the client metric for the test run. + "aggregate": "str", # Optional. The + aggregation function to be applied on the client metric. + Allowed functions - "u2018percentage"u2019 - for error metric + , "u2018avg"u2019 - for response_time_ms and latency metric. + "clientmetric": "str", # Optional. + The client metric on which the criteria should be applied. + Allowed values - "u2018response_time_ms"u2019 , + "u2018latency"u2019, "u2018error"u2019. + "condition": "str", # Optional. The + comparison operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome + of the test run. possible outcome - "u2018passed"u2019 , + "u2018failed"u2019 , "u2018undetermined"u2019. + "value": 0.0 # Optional. The value + to compare with the client metric. Allowed values - + "u2018error : [0.0 , 100.0] unit- % "u2019, response_time_ms + and latency : any integer value unit- ms. + } + } + }, + "portalUrl": "str", # Optional. Portal url. + "resourceId": "str", # Optional. Load test resource Id. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. + eg. AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the + secret, of type AKV_SECRET_URI or SECRET_VALUE. + } + }, + "startDateTime": "2020-02-20 00:00:00", # Optional. The test + run start DateTime(ISO 8601 literal format). + "status": "str", # Optional. The test run status. + "subnetId": "str", # Optional. Subnet ID on which the load + test instances should run. + "testArtifacts": { + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 + 00:00:00", # Optional. Expiry time of the file. + "fileId": "str", # Optional. + File unique identifier. + "fileType": 0, # Optional. + Integer representation of the file type (0 = JMX_FILE, 1 + = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known + values are: 0, 1, and 2. + "filename": "str", # + Optional. Name of the file. + "url": "str", # Optional. + File URL. + "validationStatus": "str" # + Optional. Validation status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", + # Optional. Expiry time of the file. + "fileId": "str", # Optional. File + unique identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: + 0, 1, and 2. + "filename": "str", # Optional. Name + of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # + Optional. Validation status of the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", + # Optional. Expiry time of the file. + "fileId": "str", # Optional. File + unique identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: + 0, 1, and 2. + "filename": "str", # Optional. Name + of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # + Optional. Validation status of the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", + # Optional. Expiry time of the file. + "fileId": "str", # Optional. File + unique identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: + 0, 1, and 2. + "filename": "str", # Optional. Name + of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # + Optional. Validation status of the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", + # Optional. Expiry time of the file. + "fileId": "str", # Optional. File + unique identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: + 0, 1, and 2. + "filename": "str", # Optional. Name + of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # + Optional. Validation status of the file. + } + }, + "outputArtifacts": { + "logsUrl": { + "expireTime": "2020-02-20 00:00:00", + # Optional. Expiry time of the file. + "fileId": "str", # Optional. File + unique identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: + 0, 1, and 2. + "filename": "str", # Optional. Name + of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # + Optional. Validation status of the file. + }, + "resultUrl": { + "expireTime": "2020-02-20 00:00:00", + # Optional. Expiry time of the file. + "fileId": "str", # Optional. File + unique identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: + 0, 1, and 2. + "filename": "str", # Optional. Name + of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # + Optional. Validation status of the file. + } + } + }, + "testId": "str", # Optional. Associated test Id. + "testResult": "str", # Optional. Test result for pass/Fail + criteria used during the test run. possible outcome - "u2018Passed"u2019 + , "u2018Failed"u2019 , "u2018Not Applicable"u2019. + "testRunId": "str", # Optional. Unique test run name as + identifier. + "testRunStatistics": { + "str": { + "errorCount": 0.0, # Optional. Error count. + "errorPct": 0.0, # Optional. Error + percentage. + "maxResTime": 0.0, # Optional. Max response + time. + "meanResTime": 0.0, # Optional. Mean + response time. + "medianResTime": 0.0, # Optional. Median + response time. + "minResTime": 0.0, # Optional. Minimum + response time. + "pct1ResTime": 0.0, # Optional. 90 + percentile response time. + "pct2ResTime": 0.0, # Optional. 95 + percentile response time. + "pct3ResTime": 0.0, # Optional. 99 + percentile response time. + "receivedKBytesPerSec": 0.0, # Optional. + Received network bytes. + "sampleCount": 0.0, # Optional. Sampler + count. + "sentKBytesPerSec": 0.0, # Optional. Sent + network bytes. + "throughput": 0.0, # Optional. Throughput. + "transaction": "str" # Optional. Transaction + name. + } + }, + "vusers": 0 # Optional. Number of virtual users, for which + test has been run. + } + ] + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_test_run_list_test_runs_search_request( + order_by=order_by, + continuation_token_parameter=continuation_token_parameter, + search=search, + execution_from=execution_from, + execution_to=execution_to, + status=status, + max_page_size=max_page_size, + test_id=test_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace_async + async def stop_test_run( + self, + test_run_id: str, + **kwargs: Any + ) -> JSON: + """Stop test run by name. + + Stop test run by name. + + :param test_run_id: Unique name of the load test run, must be a valid URL character + ^[a-z0-9_-]*$. Required. + :type test_run_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "createdBy": "str", # Optional. The user that created the test run. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The created + DateTime(ISO 8601 literal format) of the test run. + "description": "str", # Optional. The test run description. + "displayName": "str", # Optional. Display name of a test run. + "duration": 0, # Optional. Test run duration in milliseconds. + "endDateTime": "2020-02-20 00:00:00", # Optional. The test run end + DateTime(ISO 8601 literal format). + "environmentVariables": { + "str": "str" # Optional. Environment variables which are defined as + a set of pairs. + }, + "executedDateTime": "2020-02-20 00:00:00", # Optional. Test run initiated + time. + "lastModifiedBy": "str", # Optional. The user that updated the test run. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. The last updated + DateTime(ISO 8601 literal format) of the test run. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of engine instances to + execute load test. Supported values are in range of 1-45. Required for + creating a new test. + "splitAllCSVs": bool # Optional. Whether all the input CSV files + should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either "u2018stop"u2019 + or "u2018continue"u2019 after the threshold is met. Default is + "u2018continue"u2019. + "actualValue": 0.0, # Optional. The actual value of + the client metric for the test run. + "aggregate": "str", # Optional. The aggregation + function to be applied on the client metric. Allowed functions - + "u2018percentage"u2019 - for error metric , "u2018avg"u2019 - for + response_time_ms and latency metric. + "clientmetric": "str", # Optional. The client metric + on which the criteria should be applied. Allowed values - + "u2018response_time_ms"u2019 , "u2018latency"u2019, + "u2018error"u2019. + "condition": "str", # Optional. The comparison + operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome of the test + run. possible outcome - "u2018passed"u2019 , "u2018failed"u2019 , + "u2018undetermined"u2019. + "value": 0.0 # Optional. The value to compare with + the client metric. Allowed values - "u2018error : [0.0 , 100.0] unit- + % "u2019, response_time_ms and latency : any integer value unit- ms. + } + } + }, + "portalUrl": "str", # Optional. Portal url. + "resourceId": "str", # Optional. Load test resource Id. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. eg. + AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the secret, of type + AKV_SECRET_URI or SECRET_VALUE. + } + }, + "startDateTime": "2020-02-20 00:00:00", # Optional. The test run start + DateTime(ISO 8601 literal format). + "status": "str", # Optional. The test run status. + "subnetId": "str", # Optional. Subnet ID on which the load test instances + should run. + "testArtifacts": { + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", # + Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique + identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, + 1, and 2. + "filename": "str", # Optional. Name of the + file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. + Validation status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + }, + "outputArtifacts": { + "logsUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "resultUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + } + }, + "testId": "str", # Optional. Associated test Id. + "testResult": "str", # Optional. Test result for pass/Fail criteria used + during the test run. possible outcome - "u2018Passed"u2019 , "u2018Failed"u2019 , + "u2018Not Applicable"u2019. + "testRunId": "str", # Optional. Unique test run name as identifier. + "testRunStatistics": { + "str": { + "errorCount": 0.0, # Optional. Error count. + "errorPct": 0.0, # Optional. Error percentage. + "maxResTime": 0.0, # Optional. Max response time. + "meanResTime": 0.0, # Optional. Mean response time. + "medianResTime": 0.0, # Optional. Median response time. + "minResTime": 0.0, # Optional. Minimum response time. + "pct1ResTime": 0.0, # Optional. 90 percentile response time. + "pct2ResTime": 0.0, # Optional. 95 percentile response time. + "pct3ResTime": 0.0, # Optional. 99 percentile response time. + "receivedKBytesPerSec": 0.0, # Optional. Received network + bytes. + "sampleCount": 0.0, # Optional. Sampler count. + "sentKBytesPerSec": 0.0, # Optional. Sent network bytes. + "throughput": 0.0, # Optional. Throughput. + "transaction": "str" # Optional. Transaction name. + } + }, + "vusers": 0 # Optional. Number of virtual users, for which test has been + run. + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_test_run_stop_test_run_request( + test_run_id=test_run_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @overload + async def get_test_run_client_metrics( + self, + test_run_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + """Get all client metrics for a load test run. + + Get all client metrics for a load test run. + + :param test_run_id: Unique name of the load test run, must be a valid URL character + ^[a-z0-9_-]*$. Required. + :type test_run_id: str + :param body: Client metrics request model. Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "endTime": "2020-02-20 00:00:00", # End time. Required. + "errors": [ + "str" # Optional. List of errors, maximum supported errors for + queries are 20. In case of empty, by default will return metrics for maximum + 20 errors. + ], + "groupByInterval": "str", # Optional. For test duration less than 10 minutes + group by time interval can be any one of 5s,10s,1m,5m.""n""nFor test duration + greater than 10 minutes, group by time interval can be any one of 1m,5m,1h. + Default value is 1m. + "percentiles": [ + "str" # Optional. List of percentiles values for response time, + supported values 50,90,99,95. Default value is 50th percentile. + ], + "requestSamplers": [ + "str" # Optional. List of request samplers, maximum supported + samplers for queries are 20. In case of empty, it will return metrics for + maximum 20 samplers. + ], + "startTime": "2020-02-20 00:00:00" # Start time. Required. + } + + # response body for status code(s): 200 + response.json() == { + "testRunId": "str", # Optional. Test run name for which client metrics + results is required. + "timeSeries": { + "activeUsers": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + }, + "errors": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + }, + "responseTime": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + }, + "throughput": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + } + } + } + """ + + @overload + async def get_test_run_client_metrics( + self, + test_run_id: str, + body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + """Get all client metrics for a load test run. + + Get all client metrics for a load test run. + + :param test_run_id: Unique name of the load test run, must be a valid URL character + ^[a-z0-9_-]*$. Required. + :type test_run_id: str + :param body: Client metrics request model. Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "testRunId": "str", # Optional. Test run name for which client metrics + results is required. + "timeSeries": { + "activeUsers": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + }, + "errors": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + }, + "responseTime": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + }, + "throughput": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + } + } + } + """ + + + @distributed_trace_async + async def get_test_run_client_metrics( + self, + test_run_id: str, + body: Union[JSON, IO], + **kwargs: Any + ) -> JSON: + """Get all client metrics for a load test run. + + Get all client metrics for a load test run. + + :param test_run_id: Unique name of the load test run, must be a valid URL character + ^[a-z0-9_-]*$. Required. + :type test_run_id: str + :param body: Client metrics request model. Is either a model type or a IO type. Required. + :type body: JSON or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "testRunId": "str", # Optional. Test run name for which client metrics + results is required. + "timeSeries": { + "activeUsers": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + }, + "errors": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + }, + "responseTime": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + }, + "throughput": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + } + } + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = body + + request = build_test_run_get_test_run_client_metrics_request( + test_run_id=test_run_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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace_async + async def get_test_run_client_metrics_filters( + self, + test_run_id: str, + **kwargs: Any + ) -> JSON: + """Get all filters that are supported for client metrics for a given load test run. + + Get all filters that are supported for client metrics for a given load test run. + + :param test_run_id: Unique name for load test run, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type test_run_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "filters": { + "errorFiltersValues": [ + "str" # Optional. List of errors occurred for the test run, + for which client metrics can be filtered. + ], + "requestSamplerValues": [ + "str" # Optional. List of request sampler for the test run, + for which client metrics can be filtered. + ] + }, + "testRunId": "str", # Optional. Test run name for which client metrics + filters is required. + "timeRange": { + "endTime": "2020-02-20 00:00:00", # Optional. end DateTime(ISO 8601 + literal format) for the requested client metrics filter. + "startTime": "2020-02-20 00:00:00" # Optional. start DateTime(ISO + 8601 literal format) for the requested client metrics filter. + } + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_test_run_get_test_run_client_metrics_filters_request( + test_run_id=test_run_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/aio/operations/_patch.py b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/aio/operations/_patch.py new file mode 100644 index 000000000000..3ecac22be1de --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/aio/operations/_patch.py @@ -0,0 +1,91 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + +from typing import List, cast +from msrest import Serializer +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.rest import HttpRequest +from azure.core.utils import case_insensitive_dict +from ._operations import TestOperations as TestOperationsGenerated, JSON, ClsType +from ...operations._patch import build_upload_test_file_request + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +class TestOperations(TestOperationsGenerated): + """ + for performing the operations on test + """ + def __init__(self, *args, **kwargs): + super(TestOperations, self).__init__(*args, **kwargs) + + async def upload_test_file( + self, + test_id, + file_id, + file_content, + **kwargs + ) -> JSON: + """ + Uploading a test file + """ + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + _content=file_content + + request = build_upload_test_file_request( + test_id, + file_id, + _content, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + request.method = "PUT" + + pipeline_response = self._client._pipeline.run( #type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + +__all__: List[str] = ["TestOperations"] +# Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/operations/__init__.py b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/operations/__init__.py new file mode 100644 index 000000000000..c4cc1df262ad --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/operations/__init__.py @@ -0,0 +1,24 @@ +# 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 ._operations import AppComponentOperations +from ._operations import ServerMetricsOperations +from ._operations import TestOperations +from ._operations import TestRunOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'AppComponentOperations', + 'ServerMetricsOperations', + 'TestOperations', + 'TestRunOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/operations/_operations.py b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/operations/_operations.py new file mode 100644 index 000000000000..60091fc58099 --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/operations/_operations.py @@ -0,0 +1,5825 @@ +# pylint: disable=too-many-lines +# 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 abc +import datetime +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict + +from .._vendor import _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 +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_app_component_create_or_update_app_components_request( + name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/appcomponents/{name}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_app_component_delete_app_component_request( + name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/appcomponents/{name}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_app_component_get_app_component_by_name_request( + name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/appcomponents/{name}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_app_component_get_app_component_request( + *, + test_run_id: Optional[str] = None, + test_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/appcomponents" + + # Construct parameters + if test_run_id is not None: + _params['testRunId'] = _SERIALIZER.query("test_run_id", test_run_id, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if test_id is not None: + _params['testId'] = _SERIALIZER.query("test_id", test_id, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_server_metrics_create_or_update_server_metrics_config_request( + name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/serverMetricsConfig/{name}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_server_metrics_get_server_metrics_by_name_request( + name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/serverMetricsConfig/{name}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_server_metrics_delete_server_metrics_request( + name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/serverMetricsConfig/{name}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_server_metrics_get_server_metrics_request( + *, + test_run_id: Optional[str] = None, + test_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/serverMetricsConfig" + + # Construct parameters + if test_run_id is not None: + _params['testRunId'] = _SERIALIZER.query("test_run_id", test_run_id, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if test_id is not None: + _params['testId'] = _SERIALIZER.query("test_id", test_id, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_server_metrics_get_server_default_metrics_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/serverMetricsConfig/default" + + # 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_server_metrics_list_supported_resource_type_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/serverMetricsConfig/supportedResourceTypes" + + # 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_test_create_or_update_test_request( + test_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/loadtests/{testId}" + path_format_arguments = { + "testId": _SERIALIZER.url("test_id", test_id, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_test_delete_load_test_request( + test_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/loadtests/{testId}" + path_format_arguments = { + "testId": _SERIALIZER.url("test_id", test_id, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_test_get_load_test_request( + test_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/loadtests/{testId}" + path_format_arguments = { + "testId": _SERIALIZER.url("test_id", test_id, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_test_list_load_test_search_request( + *, + order_by: Optional[str] = None, + search: Optional[str] = None, + last_updated_start_time: Optional[datetime.datetime] = None, + last_updated_end_time: Optional[datetime.datetime] = None, + continuation_token_parameter: Optional[str] = None, + max_page_size: int = 50, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/loadtests/sortAndFilter" + + # Construct parameters + if order_by is not None: + _params['orderBy'] = _SERIALIZER.query("order_by", order_by, 'str') + if search is not None: + _params['search'] = _SERIALIZER.query("search", search, 'str') + if last_updated_start_time is not None: + _params['lastUpdatedStartTime'] = _SERIALIZER.query("last_updated_start_time", last_updated_start_time, 'iso-8601') + if last_updated_end_time is not None: + _params['lastUpdatedEndTime'] = _SERIALIZER.query("last_updated_end_time", last_updated_end_time, 'iso-8601') + if continuation_token_parameter is not None: + _params['continuationToken'] = _SERIALIZER.query("continuation_token_parameter", continuation_token_parameter, 'str') + if max_page_size is not None: + _params['maxPageSize'] = _SERIALIZER.query("max_page_size", max_page_size, 'int') + _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_test_upload_test_file_request( + *args, + **kwargs +) -> HttpRequest: + raise NotImplementedError( + "You need to write a custom operation for 'build_test_upload_test_file_request'. " + "Please refer to https://aka.ms/azsdk/python/dpcodegen/python/customize to learn how to customize." + ) + +def build_test_get_test_file_request( + test_id: str, + file_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/loadtests/{testId}/files/{fileId}" + path_format_arguments = { + "testId": _SERIALIZER.url("test_id", test_id, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + "fileId": _SERIALIZER.url("file_id", file_id, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_test_delete_test_file_request( + test_id: str, + file_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/loadtests/{testId}/files/{fileId}" + path_format_arguments = { + "testId": _SERIALIZER.url("test_id", test_id, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + "fileId": _SERIALIZER.url("file_id", file_id, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_test_get_all_test_files_request( + test_id: str, + *, + continuation_token_parameter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/loadtests/{testId}/files" + path_format_arguments = { + "testId": _SERIALIZER.url("test_id", test_id, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if continuation_token_parameter is not None: + _params['continuationToken'] = _SERIALIZER.query("continuation_token_parameter", continuation_token_parameter, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_test_run_delete_test_run_request( + test_run_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/testruns/{testRunId}" + path_format_arguments = { + "testRunId": _SERIALIZER.url("test_run_id", test_run_id, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_test_run_create_and_update_test_request( + test_run_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + old_test_run_id = kwargs.pop('old_test_run_id', _params.pop('oldTestRunId', None)) # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/testruns/{testRunId}" + path_format_arguments = { + "testRunId": _SERIALIZER.url("test_run_id", test_run_id, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + if old_test_run_id is not None: + _params['oldTestRunId'] = _SERIALIZER.query("old_test_run_id", old_test_run_id, 'str') + _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_test_run_get_test_run_request( + test_run_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/testruns/{testRunId}" + path_format_arguments = { + "testRunId": _SERIALIZER.url("test_run_id", test_run_id, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_test_run_get_test_run_file_request( + test_run_id: str, + file_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/testruns/{testRunId}/files/{fileId}" + path_format_arguments = { + "testRunId": _SERIALIZER.url("test_run_id", test_run_id, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + "fileId": _SERIALIZER.url("file_id", file_id, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_test_run_list_test_runs_search_request( + *, + order_by: Optional[str] = None, + continuation_token_parameter: Optional[str] = None, + search: Optional[str] = None, + execution_from: Optional[datetime.datetime] = None, + execution_to: Optional[datetime.datetime] = None, + status: Optional[str] = None, + max_page_size: int = 50, + test_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/testruns/sortAndFilter" + + # Construct parameters + if order_by is not None: + _params['orderBy'] = _SERIALIZER.query("order_by", order_by, 'str') + if continuation_token_parameter is not None: + _params['continuationToken'] = _SERIALIZER.query("continuation_token_parameter", continuation_token_parameter, 'str') + if search is not None: + _params['search'] = _SERIALIZER.query("search", search, 'str') + if execution_from is not None: + _params['executionFrom'] = _SERIALIZER.query("execution_from", execution_from, 'iso-8601') + if execution_to is not None: + _params['executionTo'] = _SERIALIZER.query("execution_to", execution_to, 'iso-8601') + if status is not None: + _params['status'] = _SERIALIZER.query("status", status, 'str') + if max_page_size is not None: + _params['maxPageSize'] = _SERIALIZER.query("max_page_size", max_page_size, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if test_id is not None: + _params['testId'] = _SERIALIZER.query("test_id", test_id, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_test_run_stop_test_run_request( + test_run_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/testruns/{testRunId}:stop" + path_format_arguments = { + "testRunId": _SERIALIZER.url("test_run_id", test_run_id, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_test_run_get_test_run_client_metrics_request( + test_run_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/testruns/{testRunId}/clientMetrics" + path_format_arguments = { + "testRunId": _SERIALIZER.url("test_run_id", test_run_id, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_test_run_get_test_run_client_metrics_filters_request( + test_run_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/testruns/{testRunId}/clientMetricsFilters" + path_format_arguments = { + "testRunId": _SERIALIZER.url("test_run_id", test_run_id, 'str', max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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 + ) + +class AppComponentOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.analytics.loadtestservice.LoadTestClient`'s + :attr:`app_component` attribute. + """ + + 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") + + + @overload + def create_or_update_app_components( + self, + name: str, + body: JSON, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> JSON: + """Associate an App Component (Azure resource) to a test or test run. + + Associate an App Component (Azure resource) to a test or test run. + + :param name: Unique name of the App Component, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type name: str + :param body: App Component model. Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", # Optional. AppComponent name. + "resourceId": "str", # Optional. Azure Load Testing resource Id. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str", # Optional. [Required if testId is not given] Load test + run unique identifier. + "value": { + "str": { + "displayName": "str", # Optional. Azure resource display + name. + "kind": "str", # Optional. Kind of Azure resource type. + "resourceGroup": "str", # Optional. Resource group name of + the Azure resource. + "resourceId": "str", # Fully qualified resource Id e.g + subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + Required. + "resourceName": "str", # Azure resource name. Required. + "resourceType": "str", # Azure resource type. Required. + "subscriptionId": "str" # Optional. Subscription Id of the + Azure resource. + } + } + } + + # response body for status code(s): 200, 201 + response.json() == { + "name": "str", # Optional. AppComponent name. + "resourceId": "str", # Optional. Azure Load Testing resource Id. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str", # Optional. [Required if testId is not given] Load test + run unique identifier. + "value": { + "str": { + "displayName": "str", # Optional. Azure resource display + name. + "kind": "str", # Optional. Kind of Azure resource type. + "resourceGroup": "str", # Optional. Resource group name of + the Azure resource. + "resourceId": "str", # Fully qualified resource Id e.g + subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + Required. + "resourceName": "str", # Azure resource name. Required. + "resourceType": "str", # Azure resource type. Required. + "subscriptionId": "str" # Optional. Subscription Id of the + Azure resource. + } + } + } + """ + + @overload + def create_or_update_app_components( + self, + name: str, + body: IO, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> JSON: + """Associate an App Component (Azure resource) to a test or test run. + + Associate an App Component (Azure resource) to a test or test run. + + :param name: Unique name of the App Component, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type name: str + :param body: App Component model. Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 201 + response.json() == { + "name": "str", # Optional. AppComponent name. + "resourceId": "str", # Optional. Azure Load Testing resource Id. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str", # Optional. [Required if testId is not given] Load test + run unique identifier. + "value": { + "str": { + "displayName": "str", # Optional. Azure resource display + name. + "kind": "str", # Optional. Kind of Azure resource type. + "resourceGroup": "str", # Optional. Resource group name of + the Azure resource. + "resourceId": "str", # Fully qualified resource Id e.g + subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + Required. + "resourceName": "str", # Azure resource name. Required. + "resourceType": "str", # Azure resource type. Required. + "subscriptionId": "str" # Optional. Subscription Id of the + Azure resource. + } + } + } + """ + + + @distributed_trace + def create_or_update_app_components( + self, + name: str, + body: Union[JSON, IO], + **kwargs: Any + ) -> JSON: + """Associate an App Component (Azure resource) to a test or test run. + + Associate an App Component (Azure resource) to a test or test run. + + :param name: Unique name of the App Component, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type name: str + :param body: App Component model. Is either a model type or a IO type. Required. + :type body: JSON or IO + :keyword content_type: Body Parameter content-type. Known values are: + 'application/merge-patch+json'. Default value is None. + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 201 + response.json() == { + "name": "str", # Optional. AppComponent name. + "resourceId": "str", # Optional. Azure Load Testing resource Id. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str", # Optional. [Required if testId is not given] Load test + run unique identifier. + "value": { + "str": { + "displayName": "str", # Optional. Azure resource display + name. + "kind": "str", # Optional. Kind of Azure resource type. + "resourceGroup": "str", # Optional. Resource group name of + the Azure resource. + "resourceId": "str", # Fully qualified resource Id e.g + subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + Required. + "resourceName": "str", # Azure resource name. Required. + "resourceType": "str", # Azure resource type. Required. + "subscriptionId": "str" # Optional. Subscription Id of the + Azure resource. + } + } + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + content_type = content_type or "application/merge-patch+json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = body + + request = build_app_component_create_or_update_app_components_request( + name=name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 201: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace + def delete_app_component( # pylint: disable=inconsistent-return-statements + self, + name: str, + **kwargs: Any + ) -> None: + """Delete an App Component. + + Delete an App Component. + + :param name: Unique name of the App Component, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_app_component_delete_app_component_request( + name=name, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + + + @distributed_trace + def get_app_component_by_name( + self, + name: str, + **kwargs: Any + ) -> JSON: + """Get App Component details by App Component name. + + Get App Component details by App Component name. + + :param name: Unique name of the App Component, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type name: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "name": "str", # Optional. AppComponent name. + "resourceId": "str", # Optional. Azure Load Testing resource Id. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str", # Optional. [Required if testId is not given] Load test + run unique identifier. + "value": { + "str": { + "displayName": "str", # Optional. Azure resource display + name. + "kind": "str", # Optional. Kind of Azure resource type. + "resourceGroup": "str", # Optional. Resource group name of + the Azure resource. + "resourceId": "str", # Fully qualified resource Id e.g + subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + Required. + "resourceName": "str", # Azure resource name. Required. + "resourceType": "str", # Azure resource type. Required. + "subscriptionId": "str" # Optional. Subscription Id of the + Azure resource. + } + } + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_app_component_get_app_component_by_name_request( + name=name, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace + def get_app_component( + self, + *, + test_run_id: Optional[str] = None, + test_id: Optional[str] = None, + **kwargs: Any + ) -> JSON: + """Get App Components for a test or a test run by its name. + + Get App Components for a test or a test run by its name. + + :keyword test_run_id: [Required, if testId is not provided] Test run Id. Default value is None. + :paramtype test_run_id: str + :keyword test_id: Unique name for load test, must be a valid URL character ^[a-z0-9_-]*$. + Default value is None. + :paramtype test_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "name": "str", # Optional. AppComponent name. + "resourceId": "str", # Optional. Azure Load Testing resource Id. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str", # Optional. [Required if testId is not given] Load test + run unique identifier. + "value": { + "str": { + "displayName": "str", # Optional. Azure resource display + name. + "kind": "str", # Optional. Kind of Azure resource type. + "resourceGroup": "str", # Optional. Resource group name of + the Azure resource. + "resourceId": "str", # Fully qualified resource Id e.g + subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + Required. + "resourceName": "str", # Azure resource name. Required. + "resourceType": "str", # Azure resource type. Required. + "subscriptionId": "str" # Optional. Subscription Id of the + Azure resource. + } + } + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_app_component_get_app_component_request( + test_run_id=test_run_id, + test_id=test_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + +class ServerMetricsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.analytics.loadtestservice.LoadTestClient`'s + :attr:`server_metrics` attribute. + """ + + 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") + + + @overload + def create_or_update_server_metrics_config( + self, + name: str, + body: JSON, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> JSON: + """Configure server metrics for a test or test run. + + Configure server metrics for a test or test run. + + :param name: Unique name for server metrics, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type name: str + :param body: Server metrics configuration model. Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "metrics": { + "str": { + "aggregation": "str", # Metric aggregation. Required. + "displayDescription": "str", # Optional. Metric description. + "id": "str", # Optional. Unique identifier for metric. + "metricnamespace": "str", # Metric name space. Required. + "name": { + "localizedValue": "str", # Metric localized name. + Required. + "value": "str" # Metric name value. Required. + }, + "resourceId": "str", # Azure resource Id. Required. + "resourceType": "str", # Azure resource type. Required. + "unit": "str" # Optional. Metric unit. + } + }, + "name": "str", # Optional. Server metrics config name. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str" # Optional. [Required, if testId is not given] Load test + run unique identifier. + } + + # response body for status code(s): 200, 201 + response.json() == { + "metrics": { + "str": { + "aggregation": "str", # Metric aggregation. Required. + "displayDescription": "str", # Optional. Metric description. + "id": "str", # Optional. Unique identifier for metric. + "metricnamespace": "str", # Metric name space. Required. + "name": { + "localizedValue": "str", # Metric localized name. + Required. + "value": "str" # Metric name value. Required. + }, + "resourceId": "str", # Azure resource Id. Required. + "resourceType": "str", # Azure resource type. Required. + "unit": "str" # Optional. Metric unit. + } + }, + "name": "str", # Optional. Server metrics config name. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str" # Optional. [Required, if testId is not given] Load test + run unique identifier. + } + """ + + @overload + def create_or_update_server_metrics_config( + self, + name: str, + body: IO, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> JSON: + """Configure server metrics for a test or test run. + + Configure server metrics for a test or test run. + + :param name: Unique name for server metrics, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type name: str + :param body: Server metrics configuration model. Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 201 + response.json() == { + "metrics": { + "str": { + "aggregation": "str", # Metric aggregation. Required. + "displayDescription": "str", # Optional. Metric description. + "id": "str", # Optional. Unique identifier for metric. + "metricnamespace": "str", # Metric name space. Required. + "name": { + "localizedValue": "str", # Metric localized name. + Required. + "value": "str" # Metric name value. Required. + }, + "resourceId": "str", # Azure resource Id. Required. + "resourceType": "str", # Azure resource type. Required. + "unit": "str" # Optional. Metric unit. + } + }, + "name": "str", # Optional. Server metrics config name. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str" # Optional. [Required, if testId is not given] Load test + run unique identifier. + } + """ + + + @distributed_trace + def create_or_update_server_metrics_config( + self, + name: str, + body: Union[JSON, IO], + **kwargs: Any + ) -> JSON: + """Configure server metrics for a test or test run. + + Configure server metrics for a test or test run. + + :param name: Unique name for server metrics, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type name: str + :param body: Server metrics configuration model. Is either a model type or a IO type. Required. + :type body: JSON or IO + :keyword content_type: Body Parameter content-type. Known values are: + 'application/merge-patch+json'. Default value is None. + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 201 + response.json() == { + "metrics": { + "str": { + "aggregation": "str", # Metric aggregation. Required. + "displayDescription": "str", # Optional. Metric description. + "id": "str", # Optional. Unique identifier for metric. + "metricnamespace": "str", # Metric name space. Required. + "name": { + "localizedValue": "str", # Metric localized name. + Required. + "value": "str" # Metric name value. Required. + }, + "resourceId": "str", # Azure resource Id. Required. + "resourceType": "str", # Azure resource type. Required. + "unit": "str" # Optional. Metric unit. + } + }, + "name": "str", # Optional. Server metrics config name. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str" # Optional. [Required, if testId is not given] Load test + run unique identifier. + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + content_type = content_type or "application/merge-patch+json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = body + + request = build_server_metrics_create_or_update_server_metrics_config_request( + name=name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 201: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace + def get_server_metrics_by_name( + self, + name: str, + **kwargs: Any + ) -> JSON: + """Get server metrics configuration by its name. + + Get server metrics configuration by its name. + + :param name: Unique name for server metrics, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type name: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "metrics": { + "str": { + "aggregation": "str", # Metric aggregation. Required. + "displayDescription": "str", # Optional. Metric description. + "id": "str", # Optional. Unique identifier for metric. + "metricnamespace": "str", # Metric name space. Required. + "name": { + "localizedValue": "str", # Metric localized name. + Required. + "value": "str" # Metric name value. Required. + }, + "resourceId": "str", # Azure resource Id. Required. + "resourceType": "str", # Azure resource type. Required. + "unit": "str" # Optional. Metric unit. + } + }, + "name": "str", # Optional. Server metrics config name. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str" # Optional. [Required, if testId is not given] Load test + run unique identifier. + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_server_metrics_get_server_metrics_by_name_request( + name=name, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace + def delete_server_metrics( # pylint: disable=inconsistent-return-statements + self, + name: str, + **kwargs: Any + ) -> None: + """Delete server metrics configuration by its name. + + Delete server metrics configuration by its name. + + :param name: Unique name for server metrics, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_server_metrics_delete_server_metrics_request( + name=name, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + + + @distributed_trace + def get_server_metrics( + self, + *, + test_run_id: Optional[str] = None, + test_id: Optional[str] = None, + **kwargs: Any + ) -> JSON: + """Get server metrics configuration for a test or test run by its name. + + Get server metrics configuration for a test or test run by its name. + + :keyword test_run_id: [Required, if testId is not provided] Test run Id. Default value is None. + :paramtype test_run_id: str + :keyword test_id: Unique name for load test, must be a valid URL character ^[a-z0-9_-]*$. + Default value is None. + :paramtype test_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "metrics": { + "str": { + "aggregation": "str", # Metric aggregation. Required. + "displayDescription": "str", # Optional. Metric description. + "id": "str", # Optional. Unique identifier for metric. + "metricnamespace": "str", # Metric name space. Required. + "name": { + "localizedValue": "str", # Metric localized name. + Required. + "value": "str" # Metric name value. Required. + }, + "resourceId": "str", # Azure resource Id. Required. + "resourceType": "str", # Azure resource type. Required. + "unit": "str" # Optional. Metric unit. + } + }, + "name": "str", # Optional. Server metrics config name. + "testId": "str", # Optional. [Required, if testRunId is not given] Load test + unique identifier. + "testRunId": "str" # Optional. [Required, if testId is not given] Load test + run unique identifier. + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_server_metrics_get_server_metrics_request( + test_run_id=test_run_id, + test_id=test_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace + def get_server_default_metrics( + self, + **kwargs: Any + ) -> JSON: + """Get all default server metrics configuration for supported resource types. + + Get all default server metrics configuration for supported resource types. + + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "defaultMetrics": { + "str": [ + { + "aggregation": "str", # Optional. Default metrics + map {resourceType : list of metrics config} (Refer for metrics + structure: + https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition). + "displayDescription": "str", # Optional. Default + metrics map {resourceType : list of metrics config} (Refer for + metrics structure: + https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition). + "metricnamespace": "str", # Optional. Default + metrics map {resourceType : list of metrics config} (Refer for + metrics structure: + https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition). + "name": { + "localizedValue": "str", # Optional. Default + metrics map {resourceType : list of metrics config} (Refer for + metrics structure: + https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition). + "value": "str" # Optional. Default metrics + map {resourceType : list of metrics config} (Refer for metrics + structure: + https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition). + }, + "unit": "str" # Optional. Default metrics map + {resourceType : list of metrics config} (Refer for metrics structure: + https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition). + } + ] + } + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_server_metrics_get_server_default_metrics_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace + def list_supported_resource_type( + self, + **kwargs: Any + ) -> JSON: + """Get all supported resource types for App Components(Azure resource types). + + Get all supported resource types for App Components(Azure resource types). + + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "value": [ + "str" # Optional. + ] + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_server_metrics_list_supported_resource_type_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + +class TestOperations(abc.ABC): + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.analytics.loadtestservice.LoadTestClient`'s + :attr:`test` attribute. + """ + + 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") + + + @overload + def create_or_update_test( + self, + test_id: str, + body: JSON, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> JSON: + """Create a new test or Update an existing test. + + Create a new test or Update an existing test. + + :param test_id: Unique name for load test, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type test_id: str + :param body: Load test model. Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "createdBy": "str", # Optional. The user that created the test model. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The created + DateTime(ISO 8601 literal format) of the test model. + "description": "str", # Optional. The test description. + "displayName": "str", # Optional. Display name of a test. + "environmentVariables": { + "str": "str" # Optional. Environment variables which are defined as + a set of pairs. + }, + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + } + }, + "keyvaultReferenceIdentityId": "str", # Optional. Resource Id of the managed + identity referencing the Key vault. + "keyvaultReferenceIdentityType": "str", # Optional. Type of the managed + identity referencing the Key vault. + "lastModifiedBy": "str", # Optional. The user that last modified the test + model. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. The last Modified + DateTime(ISO 8601 literal format) of the test model. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of engine instances to + execute load test. Supported values are in range of 1-45. Required for + creating a new test. + "splitAllCSVs": bool # Optional. Whether all the input CSV files + should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either "u2018stop"u2019 + or "u2018continue"u2019 after the threshold is met. Default is + "u2018continue"u2019. + "actualValue": 0.0, # Optional. The actual value of + the client metric for the test run. + "aggregate": "str", # Optional. The aggregation + function to be applied on the client metric. Allowed functions - + "u2018percentage"u2019 - for error metric , "u2018avg"u2019 - for + response_time_ms and latency metric. + "clientmetric": "str", # Optional. The client metric + on which the criteria should be applied. Allowed values - + "u2018response_time_ms"u2019 , "u2018latency"u2019, + "u2018error"u2019. + "condition": "str", # Optional. The comparison + operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome of the test + run. possible outcome - "u2018passed"u2019 , "u2018failed"u2019 , + "u2018undetermined"u2019. + "value": 0.0 # Optional. The value to compare with + the client metric. Allowed values - "u2018error : [0.0 , 100.0] unit- + % "u2019, response_time_ms and latency : any integer value unit- ms. + } + } + }, + "resourceId": "str", # Optional. Fully qualified resource Id e.g + /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. eg. + AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the secret, of type + AKV_SECRET_URI or SECRET_VALUE. + } + }, + "subnetId": "str", # Optional. Subnet ID on which the load test instances + should run. + "testId": "str" # Optional. Unique test name as identifier. + } + + # response body for status code(s): 200, 201 + response.json() == { + "createdBy": "str", # Optional. The user that created the test model. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The created + DateTime(ISO 8601 literal format) of the test model. + "description": "str", # Optional. The test description. + "displayName": "str", # Optional. Display name of a test. + "environmentVariables": { + "str": "str" # Optional. Environment variables which are defined as + a set of pairs. + }, + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + } + }, + "keyvaultReferenceIdentityId": "str", # Optional. Resource Id of the managed + identity referencing the Key vault. + "keyvaultReferenceIdentityType": "str", # Optional. Type of the managed + identity referencing the Key vault. + "lastModifiedBy": "str", # Optional. The user that last modified the test + model. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. The last Modified + DateTime(ISO 8601 literal format) of the test model. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of engine instances to + execute load test. Supported values are in range of 1-45. Required for + creating a new test. + "splitAllCSVs": bool # Optional. Whether all the input CSV files + should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either "u2018stop"u2019 + or "u2018continue"u2019 after the threshold is met. Default is + "u2018continue"u2019. + "actualValue": 0.0, # Optional. The actual value of + the client metric for the test run. + "aggregate": "str", # Optional. The aggregation + function to be applied on the client metric. Allowed functions - + "u2018percentage"u2019 - for error metric , "u2018avg"u2019 - for + response_time_ms and latency metric. + "clientmetric": "str", # Optional. The client metric + on which the criteria should be applied. Allowed values - + "u2018response_time_ms"u2019 , "u2018latency"u2019, + "u2018error"u2019. + "condition": "str", # Optional. The comparison + operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome of the test + run. possible outcome - "u2018passed"u2019 , "u2018failed"u2019 , + "u2018undetermined"u2019. + "value": 0.0 # Optional. The value to compare with + the client metric. Allowed values - "u2018error : [0.0 , 100.0] unit- + % "u2019, response_time_ms and latency : any integer value unit- ms. + } + } + }, + "resourceId": "str", # Optional. Fully qualified resource Id e.g + /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. eg. + AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the secret, of type + AKV_SECRET_URI or SECRET_VALUE. + } + }, + "subnetId": "str", # Optional. Subnet ID on which the load test instances + should run. + "testId": "str" # Optional. Unique test name as identifier. + } + """ + + @overload + def create_or_update_test( + self, + test_id: str, + body: IO, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> JSON: + """Create a new test or Update an existing test. + + Create a new test or Update an existing test. + + :param test_id: Unique name for load test, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type test_id: str + :param body: Load test model. Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 201 + response.json() == { + "createdBy": "str", # Optional. The user that created the test model. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The created + DateTime(ISO 8601 literal format) of the test model. + "description": "str", # Optional. The test description. + "displayName": "str", # Optional. Display name of a test. + "environmentVariables": { + "str": "str" # Optional. Environment variables which are defined as + a set of pairs. + }, + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + } + }, + "keyvaultReferenceIdentityId": "str", # Optional. Resource Id of the managed + identity referencing the Key vault. + "keyvaultReferenceIdentityType": "str", # Optional. Type of the managed + identity referencing the Key vault. + "lastModifiedBy": "str", # Optional. The user that last modified the test + model. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. The last Modified + DateTime(ISO 8601 literal format) of the test model. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of engine instances to + execute load test. Supported values are in range of 1-45. Required for + creating a new test. + "splitAllCSVs": bool # Optional. Whether all the input CSV files + should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either "u2018stop"u2019 + or "u2018continue"u2019 after the threshold is met. Default is + "u2018continue"u2019. + "actualValue": 0.0, # Optional. The actual value of + the client metric for the test run. + "aggregate": "str", # Optional. The aggregation + function to be applied on the client metric. Allowed functions - + "u2018percentage"u2019 - for error metric , "u2018avg"u2019 - for + response_time_ms and latency metric. + "clientmetric": "str", # Optional. The client metric + on which the criteria should be applied. Allowed values - + "u2018response_time_ms"u2019 , "u2018latency"u2019, + "u2018error"u2019. + "condition": "str", # Optional. The comparison + operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome of the test + run. possible outcome - "u2018passed"u2019 , "u2018failed"u2019 , + "u2018undetermined"u2019. + "value": 0.0 # Optional. The value to compare with + the client metric. Allowed values - "u2018error : [0.0 , 100.0] unit- + % "u2019, response_time_ms and latency : any integer value unit- ms. + } + } + }, + "resourceId": "str", # Optional. Fully qualified resource Id e.g + /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. eg. + AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the secret, of type + AKV_SECRET_URI or SECRET_VALUE. + } + }, + "subnetId": "str", # Optional. Subnet ID on which the load test instances + should run. + "testId": "str" # Optional. Unique test name as identifier. + } + """ + + + @distributed_trace + def create_or_update_test( + self, + test_id: str, + body: Union[JSON, IO], + **kwargs: Any + ) -> JSON: + """Create a new test or Update an existing test. + + Create a new test or Update an existing test. + + :param test_id: Unique name for load test, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type test_id: str + :param body: Load test model. Is either a model type or a IO type. Required. + :type body: JSON or IO + :keyword content_type: Body Parameter content-type. Known values are: + 'application/merge-patch+json'. Default value is None. + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 201 + response.json() == { + "createdBy": "str", # Optional. The user that created the test model. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The created + DateTime(ISO 8601 literal format) of the test model. + "description": "str", # Optional. The test description. + "displayName": "str", # Optional. Display name of a test. + "environmentVariables": { + "str": "str" # Optional. Environment variables which are defined as + a set of pairs. + }, + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + } + }, + "keyvaultReferenceIdentityId": "str", # Optional. Resource Id of the managed + identity referencing the Key vault. + "keyvaultReferenceIdentityType": "str", # Optional. Type of the managed + identity referencing the Key vault. + "lastModifiedBy": "str", # Optional. The user that last modified the test + model. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. The last Modified + DateTime(ISO 8601 literal format) of the test model. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of engine instances to + execute load test. Supported values are in range of 1-45. Required for + creating a new test. + "splitAllCSVs": bool # Optional. Whether all the input CSV files + should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either "u2018stop"u2019 + or "u2018continue"u2019 after the threshold is met. Default is + "u2018continue"u2019. + "actualValue": 0.0, # Optional. The actual value of + the client metric for the test run. + "aggregate": "str", # Optional. The aggregation + function to be applied on the client metric. Allowed functions - + "u2018percentage"u2019 - for error metric , "u2018avg"u2019 - for + response_time_ms and latency metric. + "clientmetric": "str", # Optional. The client metric + on which the criteria should be applied. Allowed values - + "u2018response_time_ms"u2019 , "u2018latency"u2019, + "u2018error"u2019. + "condition": "str", # Optional. The comparison + operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome of the test + run. possible outcome - "u2018passed"u2019 , "u2018failed"u2019 , + "u2018undetermined"u2019. + "value": 0.0 # Optional. The value to compare with + the client metric. Allowed values - "u2018error : [0.0 , 100.0] unit- + % "u2019, response_time_ms and latency : any integer value unit- ms. + } + } + }, + "resourceId": "str", # Optional. Fully qualified resource Id e.g + /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. eg. + AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the secret, of type + AKV_SECRET_URI or SECRET_VALUE. + } + }, + "subnetId": "str", # Optional. Subnet ID on which the load test instances + should run. + "testId": "str" # Optional. Unique test name as identifier. + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + content_type = content_type or "application/merge-patch+json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = body + + request = build_test_create_or_update_test_request( + test_id=test_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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 201: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace + def delete_load_test( # pylint: disable=inconsistent-return-statements + self, + test_id: str, + **kwargs: Any + ) -> None: + """Delete a test by its name. + + Delete a test by its name. + + :param test_id: Unique name for load test, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type test_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_test_delete_load_test_request( + test_id=test_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + + + @distributed_trace + def get_load_test( + self, + test_id: str, + **kwargs: Any + ) -> JSON: + """Get load test details by test name. + + Get load test details by test name. + + :param test_id: Unique name for load test, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type test_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "createdBy": "str", # Optional. The user that created the test model. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The created + DateTime(ISO 8601 literal format) of the test model. + "description": "str", # Optional. The test description. + "displayName": "str", # Optional. Display name of a test. + "environmentVariables": { + "str": "str" # Optional. Environment variables which are defined as + a set of pairs. + }, + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + } + }, + "keyvaultReferenceIdentityId": "str", # Optional. Resource Id of the managed + identity referencing the Key vault. + "keyvaultReferenceIdentityType": "str", # Optional. Type of the managed + identity referencing the Key vault. + "lastModifiedBy": "str", # Optional. The user that last modified the test + model. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. The last Modified + DateTime(ISO 8601 literal format) of the test model. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of engine instances to + execute load test. Supported values are in range of 1-45. Required for + creating a new test. + "splitAllCSVs": bool # Optional. Whether all the input CSV files + should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either "u2018stop"u2019 + or "u2018continue"u2019 after the threshold is met. Default is + "u2018continue"u2019. + "actualValue": 0.0, # Optional. The actual value of + the client metric for the test run. + "aggregate": "str", # Optional. The aggregation + function to be applied on the client metric. Allowed functions - + "u2018percentage"u2019 - for error metric , "u2018avg"u2019 - for + response_time_ms and latency metric. + "clientmetric": "str", # Optional. The client metric + on which the criteria should be applied. Allowed values - + "u2018response_time_ms"u2019 , "u2018latency"u2019, + "u2018error"u2019. + "condition": "str", # Optional. The comparison + operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome of the test + run. possible outcome - "u2018passed"u2019 , "u2018failed"u2019 , + "u2018undetermined"u2019. + "value": 0.0 # Optional. The value to compare with + the client metric. Allowed values - "u2018error : [0.0 , 100.0] unit- + % "u2019, response_time_ms and latency : any integer value unit- ms. + } + } + }, + "resourceId": "str", # Optional. Fully qualified resource Id e.g + /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. eg. + AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the secret, of type + AKV_SECRET_URI or SECRET_VALUE. + } + }, + "subnetId": "str", # Optional. Subnet ID on which the load test instances + should run. + "testId": "str" # Optional. Unique test name as identifier. + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_test_get_load_test_request( + test_id=test_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace + def list_load_test_search( + self, + *, + order_by: Optional[str] = None, + search: Optional[str] = None, + last_updated_start_time: Optional[datetime.datetime] = None, + last_updated_end_time: Optional[datetime.datetime] = None, + continuation_token_parameter: Optional[str] = None, + max_page_size: int = 50, + **kwargs: Any + ) -> JSON: + """Get all load tests by the fully qualified resource Id e.g + subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + + Get all load tests by the fully qualified resource Id e.g + subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + + :keyword order_by: Sort on one of the field - lastModifiedDateTime, displayName, createdBy in + (field asc/desc) format. eg: displayName asc. Default value is None. + :paramtype order_by: str + :keyword search: Filter search based on searchable fields - testId, createdBy. Default value is + None. + :paramtype search: str + :keyword last_updated_start_time: Start DateTime(ISO 8601 literal format) of the last updated + time range to filter tests. Default value is None. + :paramtype last_updated_start_time: ~datetime.datetime + :keyword last_updated_end_time: End DateTime(ISO 8601 literal format) of the last updated time + range to filter tests. Default value is None. + :paramtype last_updated_end_time: ~datetime.datetime + :keyword continuation_token_parameter: Continuation token to get the next page of response. + Default value is None. + :paramtype continuation_token_parameter: str + :keyword max_page_size: Number of results in response. Default value is 50. + :paramtype max_page_size: int + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str", # Optional. Link for the next list of resources in case + of paginated results, if applicable. + "value": [ + { + "createdBy": "str", # Optional. The user that created the + test model. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The + created DateTime(ISO 8601 literal format) of the test model. + "description": "str", # Optional. The test description. + "displayName": "str", # Optional. Display name of a test. + "environmentVariables": { + "str": "str" # Optional. Environment variables which + are defined as a set of pairs. + }, + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", + # Optional. Expiry time of the file. + "fileId": "str", # Optional. File + unique identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: + 0, 1, and 2. + "filename": "str", # Optional. Name + of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # + Optional. Validation status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # + Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique + identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, + 1, and 2. + "filename": "str", # Optional. Name of the + file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. + Validation status of the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # + Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique + identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, + 1, and 2. + "filename": "str", # Optional. Name of the + file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. + Validation status of the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # + Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique + identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, + 1, and 2. + "filename": "str", # Optional. Name of the + file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. + Validation status of the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # + Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique + identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, + 1, and 2. + "filename": "str", # Optional. Name of the + file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. + Validation status of the file. + } + }, + "keyvaultReferenceIdentityId": "str", # Optional. Resource + Id of the managed identity referencing the Key vault. + "keyvaultReferenceIdentityType": "str", # Optional. Type of + the managed identity referencing the Key vault. + "lastModifiedBy": "str", # Optional. The user that last + modified the test model. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. + The last Modified DateTime(ISO 8601 literal format) of the test model. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of + engine instances to execute load test. Supported values are in range + of 1-45. Required for creating a new test. + "splitAllCSVs": bool # Optional. Whether all the + input CSV files should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either + "u2018stop"u2019 or "u2018continue"u2019 after the threshold + is met. Default is "u2018continue"u2019. + "actualValue": 0.0, # Optional. The + actual value of the client metric for the test run. + "aggregate": "str", # Optional. The + aggregation function to be applied on the client metric. + Allowed functions - "u2018percentage"u2019 - for error metric + , "u2018avg"u2019 - for response_time_ms and latency metric. + "clientmetric": "str", # Optional. + The client metric on which the criteria should be applied. + Allowed values - "u2018response_time_ms"u2019 , + "u2018latency"u2019, "u2018error"u2019. + "condition": "str", # Optional. The + comparison operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome + of the test run. possible outcome - "u2018passed"u2019 , + "u2018failed"u2019 , "u2018undetermined"u2019. + "value": 0.0 # Optional. The value + to compare with the client metric. Allowed values - + "u2018error : [0.0 , 100.0] unit- % "u2019, response_time_ms + and latency : any integer value unit- ms. + } + } + }, + "resourceId": "str", # Optional. Fully qualified resource Id + e.g + /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. + eg. AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the + secret, of type AKV_SECRET_URI or SECRET_VALUE. + } + }, + "subnetId": "str", # Optional. Subnet ID on which the load + test instances should run. + "testId": "str" # Optional. Unique test name as identifier. + } + ] + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_test_list_load_test_search_request( + order_by=order_by, + search=search, + last_updated_start_time=last_updated_start_time, + last_updated_end_time=last_updated_end_time, + continuation_token_parameter=continuation_token_parameter, + max_page_size=max_page_size, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace + @abc.abstractmethod + def upload_test_file( + self, + *args, + **kwargs + ) -> JSON: + """You need to write a custom operation for "upload_test_file". Please refer to + https://aka.ms/azsdk/python/dpcodegen/python/customize to learn how to customize. + + + Example: + .. code-block:: python + + # response body for status code(s): 201 + response.json() == { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the file type (0 = + JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, 1, + and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of the file. + } + """ + + + @distributed_trace + def get_test_file( + self, + test_id: str, + file_id: str, + **kwargs: Any + ) -> JSON: + """Get test file by the file name. + + Get test file by the file name. + + :param test_id: Unique name for load test, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type test_id: str + :param file_id: Unique identifier for test file, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type file_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the file type (0 = + JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, 1, + and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of the file. + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_test_get_test_file_request( + test_id=test_id, + file_id=file_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace + def delete_test_file( # pylint: disable=inconsistent-return-statements + self, + test_id: str, + file_id: str, + **kwargs: Any + ) -> None: + """Delete file by the file name for a test. + + Delete file by the file name for a test. + + :param test_id: Unique name for load test, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type test_id: str + :param file_id: Unique identifier for test file, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type file_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_test_delete_test_file_request( + test_id=test_id, + file_id=file_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + + + @distributed_trace + def get_all_test_files( + self, + test_id: str, + *, + continuation_token_parameter: Optional[str] = None, + **kwargs: Any + ) -> JSON: + """Get all test files. + + Get all test files. + + :param test_id: Unique name for load test, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type test_id: str + :keyword continuation_token_parameter: Continuation token to get the next page of response. + Default value is None. + :paramtype continuation_token_parameter: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str", # Optional. Link for the next list of file URLs, if + applicable. + "value": [ + { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time + of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the + file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). + Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of + the file. + } + ] + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_test_get_all_test_files_request( + test_id=test_id, + continuation_token_parameter=continuation_token_parameter, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + +class TestRunOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.analytics.loadtestservice.LoadTestClient`'s + :attr:`test_run` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def delete_test_run( # pylint: disable=inconsistent-return-statements + self, + test_run_id: str, + **kwargs: Any + ) -> None: + """Delete a test run by its name. + + Delete a test run by its name. + + :param test_run_id: Unique name of the load test run, must be a valid URL character + ^[a-z0-9_-]*$. Required. + :type test_run_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_test_run_delete_test_run_request( + test_run_id=test_run_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + + + @overload + def create_and_update_test( + self, + test_run_id: str, + body: JSON, + *, + old_test_run_id: Optional[str] = None, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> JSON: + """Create and start a new test run with the given name. + + Create and start a new test run with the given name. + + :param test_run_id: Unique name of the load test run, must be a valid URL character + ^[a-z0-9_-]*$. Required. + :type test_run_id: str + :param body: Load test run model. Required. + :type body: JSON + :keyword old_test_run_id: Existing test run Id that should be rerun. Default value is None. + :paramtype old_test_run_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "createdBy": "str", # Optional. The user that created the test run. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The created + DateTime(ISO 8601 literal format) of the test run. + "description": "str", # Optional. The test run description. + "displayName": "str", # Optional. Display name of a test run. + "duration": 0, # Optional. Test run duration in milliseconds. + "endDateTime": "2020-02-20 00:00:00", # Optional. The test run end + DateTime(ISO 8601 literal format). + "environmentVariables": { + "str": "str" # Optional. Environment variables which are defined as + a set of pairs. + }, + "executedDateTime": "2020-02-20 00:00:00", # Optional. Test run initiated + time. + "lastModifiedBy": "str", # Optional. The user that updated the test run. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. The last updated + DateTime(ISO 8601 literal format) of the test run. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of engine instances to + execute load test. Supported values are in range of 1-45. Required for + creating a new test. + "splitAllCSVs": bool # Optional. Whether all the input CSV files + should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either "u2018stop"u2019 + or "u2018continue"u2019 after the threshold is met. Default is + "u2018continue"u2019. + "actualValue": 0.0, # Optional. The actual value of + the client metric for the test run. + "aggregate": "str", # Optional. The aggregation + function to be applied on the client metric. Allowed functions - + "u2018percentage"u2019 - for error metric , "u2018avg"u2019 - for + response_time_ms and latency metric. + "clientmetric": "str", # Optional. The client metric + on which the criteria should be applied. Allowed values - + "u2018response_time_ms"u2019 , "u2018latency"u2019, + "u2018error"u2019. + "condition": "str", # Optional. The comparison + operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome of the test + run. possible outcome - "u2018passed"u2019 , "u2018failed"u2019 , + "u2018undetermined"u2019. + "value": 0.0 # Optional. The value to compare with + the client metric. Allowed values - "u2018error : [0.0 , 100.0] unit- + % "u2019, response_time_ms and latency : any integer value unit- ms. + } + } + }, + "portalUrl": "str", # Optional. Portal url. + "resourceId": "str", # Optional. Load test resource Id. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. eg. + AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the secret, of type + AKV_SECRET_URI or SECRET_VALUE. + } + }, + "startDateTime": "2020-02-20 00:00:00", # Optional. The test run start + DateTime(ISO 8601 literal format). + "status": "str", # Optional. The test run status. + "subnetId": "str", # Optional. Subnet ID on which the load test instances + should run. + "testArtifacts": { + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", # + Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique + identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, + 1, and 2. + "filename": "str", # Optional. Name of the + file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. + Validation status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + }, + "outputArtifacts": { + "logsUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "resultUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + } + }, + "testId": "str", # Optional. Associated test Id. + "testResult": "str", # Optional. Test result for pass/Fail criteria used + during the test run. possible outcome - "u2018Passed"u2019 , "u2018Failed"u2019 , + "u2018Not Applicable"u2019. + "testRunId": "str", # Optional. Unique test run name as identifier. + "testRunStatistics": { + "str": { + "errorCount": 0.0, # Optional. Error count. + "errorPct": 0.0, # Optional. Error percentage. + "maxResTime": 0.0, # Optional. Max response time. + "meanResTime": 0.0, # Optional. Mean response time. + "medianResTime": 0.0, # Optional. Median response time. + "minResTime": 0.0, # Optional. Minimum response time. + "pct1ResTime": 0.0, # Optional. 90 percentile response time. + "pct2ResTime": 0.0, # Optional. 95 percentile response time. + "pct3ResTime": 0.0, # Optional. 99 percentile response time. + "receivedKBytesPerSec": 0.0, # Optional. Received network + bytes. + "sampleCount": 0.0, # Optional. Sampler count. + "sentKBytesPerSec": 0.0, # Optional. Sent network bytes. + "throughput": 0.0, # Optional. Throughput. + "transaction": "str" # Optional. Transaction name. + } + }, + "vusers": 0 # Optional. Number of virtual users, for which test has been + run. + } + + # response body for status code(s): 200 + response.json() == { + "createdBy": "str", # Optional. The user that created the test run. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The created + DateTime(ISO 8601 literal format) of the test run. + "description": "str", # Optional. The test run description. + "displayName": "str", # Optional. Display name of a test run. + "duration": 0, # Optional. Test run duration in milliseconds. + "endDateTime": "2020-02-20 00:00:00", # Optional. The test run end + DateTime(ISO 8601 literal format). + "environmentVariables": { + "str": "str" # Optional. Environment variables which are defined as + a set of pairs. + }, + "executedDateTime": "2020-02-20 00:00:00", # Optional. Test run initiated + time. + "lastModifiedBy": "str", # Optional. The user that updated the test run. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. The last updated + DateTime(ISO 8601 literal format) of the test run. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of engine instances to + execute load test. Supported values are in range of 1-45. Required for + creating a new test. + "splitAllCSVs": bool # Optional. Whether all the input CSV files + should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either "u2018stop"u2019 + or "u2018continue"u2019 after the threshold is met. Default is + "u2018continue"u2019. + "actualValue": 0.0, # Optional. The actual value of + the client metric for the test run. + "aggregate": "str", # Optional. The aggregation + function to be applied on the client metric. Allowed functions - + "u2018percentage"u2019 - for error metric , "u2018avg"u2019 - for + response_time_ms and latency metric. + "clientmetric": "str", # Optional. The client metric + on which the criteria should be applied. Allowed values - + "u2018response_time_ms"u2019 , "u2018latency"u2019, + "u2018error"u2019. + "condition": "str", # Optional. The comparison + operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome of the test + run. possible outcome - "u2018passed"u2019 , "u2018failed"u2019 , + "u2018undetermined"u2019. + "value": 0.0 # Optional. The value to compare with + the client metric. Allowed values - "u2018error : [0.0 , 100.0] unit- + % "u2019, response_time_ms and latency : any integer value unit- ms. + } + } + }, + "portalUrl": "str", # Optional. Portal url. + "resourceId": "str", # Optional. Load test resource Id. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. eg. + AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the secret, of type + AKV_SECRET_URI or SECRET_VALUE. + } + }, + "startDateTime": "2020-02-20 00:00:00", # Optional. The test run start + DateTime(ISO 8601 literal format). + "status": "str", # Optional. The test run status. + "subnetId": "str", # Optional. Subnet ID on which the load test instances + should run. + "testArtifacts": { + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", # + Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique + identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, + 1, and 2. + "filename": "str", # Optional. Name of the + file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. + Validation status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + }, + "outputArtifacts": { + "logsUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "resultUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + } + }, + "testId": "str", # Optional. Associated test Id. + "testResult": "str", # Optional. Test result for pass/Fail criteria used + during the test run. possible outcome - "u2018Passed"u2019 , "u2018Failed"u2019 , + "u2018Not Applicable"u2019. + "testRunId": "str", # Optional. Unique test run name as identifier. + "testRunStatistics": { + "str": { + "errorCount": 0.0, # Optional. Error count. + "errorPct": 0.0, # Optional. Error percentage. + "maxResTime": 0.0, # Optional. Max response time. + "meanResTime": 0.0, # Optional. Mean response time. + "medianResTime": 0.0, # Optional. Median response time. + "minResTime": 0.0, # Optional. Minimum response time. + "pct1ResTime": 0.0, # Optional. 90 percentile response time. + "pct2ResTime": 0.0, # Optional. 95 percentile response time. + "pct3ResTime": 0.0, # Optional. 99 percentile response time. + "receivedKBytesPerSec": 0.0, # Optional. Received network + bytes. + "sampleCount": 0.0, # Optional. Sampler count. + "sentKBytesPerSec": 0.0, # Optional. Sent network bytes. + "throughput": 0.0, # Optional. Throughput. + "transaction": "str" # Optional. Transaction name. + } + }, + "vusers": 0 # Optional. Number of virtual users, for which test has been + run. + } + """ + + @overload + def create_and_update_test( + self, + test_run_id: str, + body: IO, + *, + old_test_run_id: Optional[str] = None, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> JSON: + """Create and start a new test run with the given name. + + Create and start a new test run with the given name. + + :param test_run_id: Unique name of the load test run, must be a valid URL character + ^[a-z0-9_-]*$. Required. + :type test_run_id: str + :param body: Load test run model. Required. + :type body: IO + :keyword old_test_run_id: Existing test run Id that should be rerun. Default value is None. + :paramtype old_test_run_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "createdBy": "str", # Optional. The user that created the test run. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The created + DateTime(ISO 8601 literal format) of the test run. + "description": "str", # Optional. The test run description. + "displayName": "str", # Optional. Display name of a test run. + "duration": 0, # Optional. Test run duration in milliseconds. + "endDateTime": "2020-02-20 00:00:00", # Optional. The test run end + DateTime(ISO 8601 literal format). + "environmentVariables": { + "str": "str" # Optional. Environment variables which are defined as + a set of pairs. + }, + "executedDateTime": "2020-02-20 00:00:00", # Optional. Test run initiated + time. + "lastModifiedBy": "str", # Optional. The user that updated the test run. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. The last updated + DateTime(ISO 8601 literal format) of the test run. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of engine instances to + execute load test. Supported values are in range of 1-45. Required for + creating a new test. + "splitAllCSVs": bool # Optional. Whether all the input CSV files + should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either "u2018stop"u2019 + or "u2018continue"u2019 after the threshold is met. Default is + "u2018continue"u2019. + "actualValue": 0.0, # Optional. The actual value of + the client metric for the test run. + "aggregate": "str", # Optional. The aggregation + function to be applied on the client metric. Allowed functions - + "u2018percentage"u2019 - for error metric , "u2018avg"u2019 - for + response_time_ms and latency metric. + "clientmetric": "str", # Optional. The client metric + on which the criteria should be applied. Allowed values - + "u2018response_time_ms"u2019 , "u2018latency"u2019, + "u2018error"u2019. + "condition": "str", # Optional. The comparison + operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome of the test + run. possible outcome - "u2018passed"u2019 , "u2018failed"u2019 , + "u2018undetermined"u2019. + "value": 0.0 # Optional. The value to compare with + the client metric. Allowed values - "u2018error : [0.0 , 100.0] unit- + % "u2019, response_time_ms and latency : any integer value unit- ms. + } + } + }, + "portalUrl": "str", # Optional. Portal url. + "resourceId": "str", # Optional. Load test resource Id. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. eg. + AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the secret, of type + AKV_SECRET_URI or SECRET_VALUE. + } + }, + "startDateTime": "2020-02-20 00:00:00", # Optional. The test run start + DateTime(ISO 8601 literal format). + "status": "str", # Optional. The test run status. + "subnetId": "str", # Optional. Subnet ID on which the load test instances + should run. + "testArtifacts": { + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", # + Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique + identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, + 1, and 2. + "filename": "str", # Optional. Name of the + file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. + Validation status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + }, + "outputArtifacts": { + "logsUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "resultUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + } + }, + "testId": "str", # Optional. Associated test Id. + "testResult": "str", # Optional. Test result for pass/Fail criteria used + during the test run. possible outcome - "u2018Passed"u2019 , "u2018Failed"u2019 , + "u2018Not Applicable"u2019. + "testRunId": "str", # Optional. Unique test run name as identifier. + "testRunStatistics": { + "str": { + "errorCount": 0.0, # Optional. Error count. + "errorPct": 0.0, # Optional. Error percentage. + "maxResTime": 0.0, # Optional. Max response time. + "meanResTime": 0.0, # Optional. Mean response time. + "medianResTime": 0.0, # Optional. Median response time. + "minResTime": 0.0, # Optional. Minimum response time. + "pct1ResTime": 0.0, # Optional. 90 percentile response time. + "pct2ResTime": 0.0, # Optional. 95 percentile response time. + "pct3ResTime": 0.0, # Optional. 99 percentile response time. + "receivedKBytesPerSec": 0.0, # Optional. Received network + bytes. + "sampleCount": 0.0, # Optional. Sampler count. + "sentKBytesPerSec": 0.0, # Optional. Sent network bytes. + "throughput": 0.0, # Optional. Throughput. + "transaction": "str" # Optional. Transaction name. + } + }, + "vusers": 0 # Optional. Number of virtual users, for which test has been + run. + } + """ + + + @distributed_trace + def create_and_update_test( + self, + test_run_id: str, + body: Union[JSON, IO], + *, + old_test_run_id: Optional[str] = None, + **kwargs: Any + ) -> JSON: + """Create and start a new test run with the given name. + + Create and start a new test run with the given name. + + :param test_run_id: Unique name of the load test run, must be a valid URL character + ^[a-z0-9_-]*$. Required. + :type test_run_id: str + :param body: Load test run model. Is either a model type or a IO type. Required. + :type body: JSON or IO + :keyword old_test_run_id: Existing test run Id that should be rerun. Default value is None. + :paramtype old_test_run_id: str + :keyword content_type: Body Parameter content-type. Known values are: + 'application/merge-patch+json'. Default value is None. + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "createdBy": "str", # Optional. The user that created the test run. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The created + DateTime(ISO 8601 literal format) of the test run. + "description": "str", # Optional. The test run description. + "displayName": "str", # Optional. Display name of a test run. + "duration": 0, # Optional. Test run duration in milliseconds. + "endDateTime": "2020-02-20 00:00:00", # Optional. The test run end + DateTime(ISO 8601 literal format). + "environmentVariables": { + "str": "str" # Optional. Environment variables which are defined as + a set of pairs. + }, + "executedDateTime": "2020-02-20 00:00:00", # Optional. Test run initiated + time. + "lastModifiedBy": "str", # Optional. The user that updated the test run. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. The last updated + DateTime(ISO 8601 literal format) of the test run. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of engine instances to + execute load test. Supported values are in range of 1-45. Required for + creating a new test. + "splitAllCSVs": bool # Optional. Whether all the input CSV files + should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either "u2018stop"u2019 + or "u2018continue"u2019 after the threshold is met. Default is + "u2018continue"u2019. + "actualValue": 0.0, # Optional. The actual value of + the client metric for the test run. + "aggregate": "str", # Optional. The aggregation + function to be applied on the client metric. Allowed functions - + "u2018percentage"u2019 - for error metric , "u2018avg"u2019 - for + response_time_ms and latency metric. + "clientmetric": "str", # Optional. The client metric + on which the criteria should be applied. Allowed values - + "u2018response_time_ms"u2019 , "u2018latency"u2019, + "u2018error"u2019. + "condition": "str", # Optional. The comparison + operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome of the test + run. possible outcome - "u2018passed"u2019 , "u2018failed"u2019 , + "u2018undetermined"u2019. + "value": 0.0 # Optional. The value to compare with + the client metric. Allowed values - "u2018error : [0.0 , 100.0] unit- + % "u2019, response_time_ms and latency : any integer value unit- ms. + } + } + }, + "portalUrl": "str", # Optional. Portal url. + "resourceId": "str", # Optional. Load test resource Id. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. eg. + AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the secret, of type + AKV_SECRET_URI or SECRET_VALUE. + } + }, + "startDateTime": "2020-02-20 00:00:00", # Optional. The test run start + DateTime(ISO 8601 literal format). + "status": "str", # Optional. The test run status. + "subnetId": "str", # Optional. Subnet ID on which the load test instances + should run. + "testArtifacts": { + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", # + Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique + identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, + 1, and 2. + "filename": "str", # Optional. Name of the + file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. + Validation status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + }, + "outputArtifacts": { + "logsUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "resultUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + } + }, + "testId": "str", # Optional. Associated test Id. + "testResult": "str", # Optional. Test result for pass/Fail criteria used + during the test run. possible outcome - "u2018Passed"u2019 , "u2018Failed"u2019 , + "u2018Not Applicable"u2019. + "testRunId": "str", # Optional. Unique test run name as identifier. + "testRunStatistics": { + "str": { + "errorCount": 0.0, # Optional. Error count. + "errorPct": 0.0, # Optional. Error percentage. + "maxResTime": 0.0, # Optional. Max response time. + "meanResTime": 0.0, # Optional. Mean response time. + "medianResTime": 0.0, # Optional. Median response time. + "minResTime": 0.0, # Optional. Minimum response time. + "pct1ResTime": 0.0, # Optional. 90 percentile response time. + "pct2ResTime": 0.0, # Optional. 95 percentile response time. + "pct3ResTime": 0.0, # Optional. 99 percentile response time. + "receivedKBytesPerSec": 0.0, # Optional. Received network + bytes. + "sampleCount": 0.0, # Optional. Sampler count. + "sentKBytesPerSec": 0.0, # Optional. Sent network bytes. + "throughput": 0.0, # Optional. Throughput. + "transaction": "str" # Optional. Transaction name. + } + }, + "vusers": 0 # Optional. Number of virtual users, for which test has been + run. + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + content_type = content_type or "application/merge-patch+json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = body + + request = build_test_run_create_and_update_test_request( + test_run_id=test_run_id, + old_test_run_id=old_test_run_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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace + def get_test_run( + self, + test_run_id: str, + **kwargs: Any + ) -> JSON: + """Get test run details by name. + + Get test run details by name. + + :param test_run_id: Unique name of load test run, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type test_run_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "createdBy": "str", # Optional. The user that created the test run. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The created + DateTime(ISO 8601 literal format) of the test run. + "description": "str", # Optional. The test run description. + "displayName": "str", # Optional. Display name of a test run. + "duration": 0, # Optional. Test run duration in milliseconds. + "endDateTime": "2020-02-20 00:00:00", # Optional. The test run end + DateTime(ISO 8601 literal format). + "environmentVariables": { + "str": "str" # Optional. Environment variables which are defined as + a set of pairs. + }, + "executedDateTime": "2020-02-20 00:00:00", # Optional. Test run initiated + time. + "lastModifiedBy": "str", # Optional. The user that updated the test run. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. The last updated + DateTime(ISO 8601 literal format) of the test run. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of engine instances to + execute load test. Supported values are in range of 1-45. Required for + creating a new test. + "splitAllCSVs": bool # Optional. Whether all the input CSV files + should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either "u2018stop"u2019 + or "u2018continue"u2019 after the threshold is met. Default is + "u2018continue"u2019. + "actualValue": 0.0, # Optional. The actual value of + the client metric for the test run. + "aggregate": "str", # Optional. The aggregation + function to be applied on the client metric. Allowed functions - + "u2018percentage"u2019 - for error metric , "u2018avg"u2019 - for + response_time_ms and latency metric. + "clientmetric": "str", # Optional. The client metric + on which the criteria should be applied. Allowed values - + "u2018response_time_ms"u2019 , "u2018latency"u2019, + "u2018error"u2019. + "condition": "str", # Optional. The comparison + operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome of the test + run. possible outcome - "u2018passed"u2019 , "u2018failed"u2019 , + "u2018undetermined"u2019. + "value": 0.0 # Optional. The value to compare with + the client metric. Allowed values - "u2018error : [0.0 , 100.0] unit- + % "u2019, response_time_ms and latency : any integer value unit- ms. + } + } + }, + "portalUrl": "str", # Optional. Portal url. + "resourceId": "str", # Optional. Load test resource Id. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. eg. + AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the secret, of type + AKV_SECRET_URI or SECRET_VALUE. + } + }, + "startDateTime": "2020-02-20 00:00:00", # Optional. The test run start + DateTime(ISO 8601 literal format). + "status": "str", # Optional. The test run status. + "subnetId": "str", # Optional. Subnet ID on which the load test instances + should run. + "testArtifacts": { + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", # + Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique + identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, + 1, and 2. + "filename": "str", # Optional. Name of the + file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. + Validation status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + }, + "outputArtifacts": { + "logsUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "resultUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + } + }, + "testId": "str", # Optional. Associated test Id. + "testResult": "str", # Optional. Test result for pass/Fail criteria used + during the test run. possible outcome - "u2018Passed"u2019 , "u2018Failed"u2019 , + "u2018Not Applicable"u2019. + "testRunId": "str", # Optional. Unique test run name as identifier. + "testRunStatistics": { + "str": { + "errorCount": 0.0, # Optional. Error count. + "errorPct": 0.0, # Optional. Error percentage. + "maxResTime": 0.0, # Optional. Max response time. + "meanResTime": 0.0, # Optional. Mean response time. + "medianResTime": 0.0, # Optional. Median response time. + "minResTime": 0.0, # Optional. Minimum response time. + "pct1ResTime": 0.0, # Optional. 90 percentile response time. + "pct2ResTime": 0.0, # Optional. 95 percentile response time. + "pct3ResTime": 0.0, # Optional. 99 percentile response time. + "receivedKBytesPerSec": 0.0, # Optional. Received network + bytes. + "sampleCount": 0.0, # Optional. Sampler count. + "sentKBytesPerSec": 0.0, # Optional. Sent network bytes. + "throughput": 0.0, # Optional. Throughput. + "transaction": "str" # Optional. Transaction name. + } + }, + "vusers": 0 # Optional. Number of virtual users, for which test has been + run. + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_test_run_get_test_run_request( + test_run_id=test_run_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace + def get_test_run_file( + self, + test_run_id: str, + file_id: str, + **kwargs: Any + ) -> JSON: + """Get test run file by file name. + + Get test run file by file name. + + :param test_run_id: Unique name of load test run, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type test_run_id: str + :param file_id: Unique identifier for test run file, must be a valid URL character + ^[a-z0-9_-]*$. Required. + :type file_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "expireTime": "2020-02-20 00:00:00", # Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of the file type (0 = + JMX_FILE, 1 = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, 1, + and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation status of the file. + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_test_run_get_test_run_file_request( + test_run_id=test_run_id, + file_id=file_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace + def list_test_runs_search( + self, + *, + order_by: Optional[str] = None, + continuation_token_parameter: Optional[str] = None, + search: Optional[str] = None, + execution_from: Optional[datetime.datetime] = None, + execution_to: Optional[datetime.datetime] = None, + status: Optional[str] = None, + max_page_size: int = 50, + test_id: Optional[str] = None, + **kwargs: Any + ) -> JSON: + """Get all test runs with given filters. + + Get all test runs with given filters. + + :keyword order_by: Sort on one of the field - status, displayName, executedDateTime in (field + asc/desc) format. eg: displayName asc. Default value is None. + :paramtype order_by: str + :keyword continuation_token_parameter: Continuation token to get the next page of response. + Default value is None. + :paramtype continuation_token_parameter: str + :keyword search: Filter search based on searchable fields - description, executedUser. Default + value is None. + :paramtype search: str + :keyword execution_from: The end DateTime(ISO 8601 literal format) of test-run execution time + filter range. Default value is None. + :paramtype execution_from: ~datetime.datetime + :keyword execution_to: The start DateTime(ISO 8601 literal format) of test-run execution time + filter range. Default value is None. + :paramtype execution_to: ~datetime.datetime + :keyword status: Comma separated list of test run status, value can be - "ACCEPTED", + "NOTSTARTED","PROVISIONING","PROVISIONED","CONFIGURING", + "CONFIGURED","EXECUTING","EXECUTED","DEPROVISIONING","DEPROVISIONED","DONE","CANCELLED","FAILED". + Default value is None. + :paramtype status: str + :keyword max_page_size: Number of results in response. Default value is 50. + :paramtype max_page_size: int + :keyword test_id: Unique name for load test, must be a valid URL character ^[a-z0-9_-]*$. + Default value is None. + :paramtype test_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "nextLink": "str", # Optional. Link for the next list of resources in case + of paginated results, if applicable. + "value": [ + { + "createdBy": "str", # Optional. The user that created the + test run. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The + created DateTime(ISO 8601 literal format) of the test run. + "description": "str", # Optional. The test run description. + "displayName": "str", # Optional. Display name of a test + run. + "duration": 0, # Optional. Test run duration in + milliseconds. + "endDateTime": "2020-02-20 00:00:00", # Optional. The test + run end DateTime(ISO 8601 literal format). + "environmentVariables": { + "str": "str" # Optional. Environment variables which + are defined as a set of pairs. + }, + "executedDateTime": "2020-02-20 00:00:00", # Optional. Test + run initiated time. + "lastModifiedBy": "str", # Optional. The user that updated + the test run. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. + The last updated DateTime(ISO 8601 literal format) of the test run. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of + engine instances to execute load test. Supported values are in range + of 1-45. Required for creating a new test. + "splitAllCSVs": bool # Optional. Whether all the + input CSV files should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either + "u2018stop"u2019 or "u2018continue"u2019 after the threshold + is met. Default is "u2018continue"u2019. + "actualValue": 0.0, # Optional. The + actual value of the client metric for the test run. + "aggregate": "str", # Optional. The + aggregation function to be applied on the client metric. + Allowed functions - "u2018percentage"u2019 - for error metric + , "u2018avg"u2019 - for response_time_ms and latency metric. + "clientmetric": "str", # Optional. + The client metric on which the criteria should be applied. + Allowed values - "u2018response_time_ms"u2019 , + "u2018latency"u2019, "u2018error"u2019. + "condition": "str", # Optional. The + comparison operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome + of the test run. possible outcome - "u2018passed"u2019 , + "u2018failed"u2019 , "u2018undetermined"u2019. + "value": 0.0 # Optional. The value + to compare with the client metric. Allowed values - + "u2018error : [0.0 , 100.0] unit- % "u2019, response_time_ms + and latency : any integer value unit- ms. + } + } + }, + "portalUrl": "str", # Optional. Portal url. + "resourceId": "str", # Optional. Load test resource Id. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. + eg. AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the + secret, of type AKV_SECRET_URI or SECRET_VALUE. + } + }, + "startDateTime": "2020-02-20 00:00:00", # Optional. The test + run start DateTime(ISO 8601 literal format). + "status": "str", # Optional. The test run status. + "subnetId": "str", # Optional. Subnet ID on which the load + test instances should run. + "testArtifacts": { + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 + 00:00:00", # Optional. Expiry time of the file. + "fileId": "str", # Optional. + File unique identifier. + "fileType": 0, # Optional. + Integer representation of the file type (0 = JMX_FILE, 1 + = USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known + values are: 0, 1, and 2. + "filename": "str", # + Optional. Name of the file. + "url": "str", # Optional. + File URL. + "validationStatus": "str" # + Optional. Validation status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", + # Optional. Expiry time of the file. + "fileId": "str", # Optional. File + unique identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: + 0, 1, and 2. + "filename": "str", # Optional. Name + of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # + Optional. Validation status of the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", + # Optional. Expiry time of the file. + "fileId": "str", # Optional. File + unique identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: + 0, 1, and 2. + "filename": "str", # Optional. Name + of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # + Optional. Validation status of the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", + # Optional. Expiry time of the file. + "fileId": "str", # Optional. File + unique identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: + 0, 1, and 2. + "filename": "str", # Optional. Name + of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # + Optional. Validation status of the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", + # Optional. Expiry time of the file. + "fileId": "str", # Optional. File + unique identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: + 0, 1, and 2. + "filename": "str", # Optional. Name + of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # + Optional. Validation status of the file. + } + }, + "outputArtifacts": { + "logsUrl": { + "expireTime": "2020-02-20 00:00:00", + # Optional. Expiry time of the file. + "fileId": "str", # Optional. File + unique identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: + 0, 1, and 2. + "filename": "str", # Optional. Name + of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # + Optional. Validation status of the file. + }, + "resultUrl": { + "expireTime": "2020-02-20 00:00:00", + # Optional. Expiry time of the file. + "fileId": "str", # Optional. File + unique identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: + 0, 1, and 2. + "filename": "str", # Optional. Name + of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # + Optional. Validation status of the file. + } + } + }, + "testId": "str", # Optional. Associated test Id. + "testResult": "str", # Optional. Test result for pass/Fail + criteria used during the test run. possible outcome - "u2018Passed"u2019 + , "u2018Failed"u2019 , "u2018Not Applicable"u2019. + "testRunId": "str", # Optional. Unique test run name as + identifier. + "testRunStatistics": { + "str": { + "errorCount": 0.0, # Optional. Error count. + "errorPct": 0.0, # Optional. Error + percentage. + "maxResTime": 0.0, # Optional. Max response + time. + "meanResTime": 0.0, # Optional. Mean + response time. + "medianResTime": 0.0, # Optional. Median + response time. + "minResTime": 0.0, # Optional. Minimum + response time. + "pct1ResTime": 0.0, # Optional. 90 + percentile response time. + "pct2ResTime": 0.0, # Optional. 95 + percentile response time. + "pct3ResTime": 0.0, # Optional. 99 + percentile response time. + "receivedKBytesPerSec": 0.0, # Optional. + Received network bytes. + "sampleCount": 0.0, # Optional. Sampler + count. + "sentKBytesPerSec": 0.0, # Optional. Sent + network bytes. + "throughput": 0.0, # Optional. Throughput. + "transaction": "str" # Optional. Transaction + name. + } + }, + "vusers": 0 # Optional. Number of virtual users, for which + test has been run. + } + ] + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_test_run_list_test_runs_search_request( + order_by=order_by, + continuation_token_parameter=continuation_token_parameter, + search=search, + execution_from=execution_from, + execution_to=execution_to, + status=status, + max_page_size=max_page_size, + test_id=test_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace + def stop_test_run( + self, + test_run_id: str, + **kwargs: Any + ) -> JSON: + """Stop test run by name. + + Stop test run by name. + + :param test_run_id: Unique name of the load test run, must be a valid URL character + ^[a-z0-9_-]*$. Required. + :type test_run_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "createdBy": "str", # Optional. The user that created the test run. + "createdDateTime": "2020-02-20 00:00:00", # Optional. The created + DateTime(ISO 8601 literal format) of the test run. + "description": "str", # Optional. The test run description. + "displayName": "str", # Optional. Display name of a test run. + "duration": 0, # Optional. Test run duration in milliseconds. + "endDateTime": "2020-02-20 00:00:00", # Optional. The test run end + DateTime(ISO 8601 literal format). + "environmentVariables": { + "str": "str" # Optional. Environment variables which are defined as + a set of pairs. + }, + "executedDateTime": "2020-02-20 00:00:00", # Optional. Test run initiated + time. + "lastModifiedBy": "str", # Optional. The user that updated the test run. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. The last updated + DateTime(ISO 8601 literal format) of the test run. + "loadTestConfig": { + "engineInstances": 0, # Optional. The number of engine instances to + execute load test. Supported values are in range of 1-45. Required for + creating a new test. + "splitAllCSVs": bool # Optional. Whether all the input CSV files + should be split evenly across all engines. + }, + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", # Optional. Either "u2018stop"u2019 + or "u2018continue"u2019 after the threshold is met. Default is + "u2018continue"u2019. + "actualValue": 0.0, # Optional. The actual value of + the client metric for the test run. + "aggregate": "str", # Optional. The aggregation + function to be applied on the client metric. Allowed functions - + "u2018percentage"u2019 - for error metric , "u2018avg"u2019 - for + response_time_ms and latency metric. + "clientmetric": "str", # Optional. The client metric + on which the criteria should be applied. Allowed values - + "u2018response_time_ms"u2019 , "u2018latency"u2019, + "u2018error"u2019. + "condition": "str", # Optional. The comparison + operator. Supported types "u2018>"u2019. + "result": "str", # Optional. Outcome of the test + run. possible outcome - "u2018passed"u2019 , "u2018failed"u2019 , + "u2018undetermined"u2019. + "value": 0.0 # Optional. The value to compare with + the client metric. Allowed values - "u2018error : [0.0 , 100.0] unit- + % "u2019, response_time_ms and latency : any integer value unit- ms. + } + } + }, + "portalUrl": "str", # Optional. Portal url. + "resourceId": "str", # Optional. Load test resource Id. + "secrets": { + "str": { + "type": "str", # Optional. Type of secret. eg. + AKV_SECRET_URI/SECRET_VALUE. + "value": "str" # Optional. The value of the secret, of type + AKV_SECRET_URI or SECRET_VALUE. + } + }, + "startDateTime": "2020-02-20 00:00:00", # Optional. The test run start + DateTime(ISO 8601 literal format). + "status": "str", # Optional. The test run status. + "subnetId": "str", # Optional. Subnet ID on which the load test instances + should run. + "testArtifacts": { + "inputArtifacts": { + "additionalUrls": [ + { + "expireTime": "2020-02-20 00:00:00", # + Optional. Expiry time of the file. + "fileId": "str", # Optional. File unique + identifier. + "fileType": 0, # Optional. Integer + representation of the file type (0 = JMX_FILE, 1 = + USER_PROPERTIES, 2 = ADDITIONAL_ARTIFACTS). Known values are: 0, + 1, and 2. + "filename": "str", # Optional. Name of the + file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. + Validation status of the file. + } + ], + "configUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "inputArtifactsZipFileurl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "testScriptUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "userPropUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + }, + "outputArtifacts": { + "logsUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + }, + "resultUrl": { + "expireTime": "2020-02-20 00:00:00", # Optional. + Expiry time of the file. + "fileId": "str", # Optional. File unique identifier. + "fileType": 0, # Optional. Integer representation of + the file type (0 = JMX_FILE, 1 = USER_PROPERTIES, 2 = + ADDITIONAL_ARTIFACTS). Known values are: 0, 1, and 2. + "filename": "str", # Optional. Name of the file. + "url": "str", # Optional. File URL. + "validationStatus": "str" # Optional. Validation + status of the file. + } + } + }, + "testId": "str", # Optional. Associated test Id. + "testResult": "str", # Optional. Test result for pass/Fail criteria used + during the test run. possible outcome - "u2018Passed"u2019 , "u2018Failed"u2019 , + "u2018Not Applicable"u2019. + "testRunId": "str", # Optional. Unique test run name as identifier. + "testRunStatistics": { + "str": { + "errorCount": 0.0, # Optional. Error count. + "errorPct": 0.0, # Optional. Error percentage. + "maxResTime": 0.0, # Optional. Max response time. + "meanResTime": 0.0, # Optional. Mean response time. + "medianResTime": 0.0, # Optional. Median response time. + "minResTime": 0.0, # Optional. Minimum response time. + "pct1ResTime": 0.0, # Optional. 90 percentile response time. + "pct2ResTime": 0.0, # Optional. 95 percentile response time. + "pct3ResTime": 0.0, # Optional. 99 percentile response time. + "receivedKBytesPerSec": 0.0, # Optional. Received network + bytes. + "sampleCount": 0.0, # Optional. Sampler count. + "sentKBytesPerSec": 0.0, # Optional. Sent network bytes. + "throughput": 0.0, # Optional. Throughput. + "transaction": "str" # Optional. Transaction name. + } + }, + "vusers": 0 # Optional. Number of virtual users, for which test has been + run. + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_test_run_stop_test_run_request( + test_run_id=test_run_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @overload + def get_test_run_client_metrics( + self, + test_run_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + """Get all client metrics for a load test run. + + Get all client metrics for a load test run. + + :param test_run_id: Unique name of the load test run, must be a valid URL character + ^[a-z0-9_-]*$. Required. + :type test_run_id: str + :param body: Client metrics request model. Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "endTime": "2020-02-20 00:00:00", # End time. Required. + "errors": [ + "str" # Optional. List of errors, maximum supported errors for + queries are 20. In case of empty, by default will return metrics for maximum + 20 errors. + ], + "groupByInterval": "str", # Optional. For test duration less than 10 minutes + group by time interval can be any one of 5s,10s,1m,5m.""n""nFor test duration + greater than 10 minutes, group by time interval can be any one of 1m,5m,1h. + Default value is 1m. + "percentiles": [ + "str" # Optional. List of percentiles values for response time, + supported values 50,90,99,95. Default value is 50th percentile. + ], + "requestSamplers": [ + "str" # Optional. List of request samplers, maximum supported + samplers for queries are 20. In case of empty, it will return metrics for + maximum 20 samplers. + ], + "startTime": "2020-02-20 00:00:00" # Start time. Required. + } + + # response body for status code(s): 200 + response.json() == { + "testRunId": "str", # Optional. Test run name for which client metrics + results is required. + "timeSeries": { + "activeUsers": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + }, + "errors": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + }, + "responseTime": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + }, + "throughput": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + } + } + } + """ + + @overload + def get_test_run_client_metrics( + self, + test_run_id: str, + body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + """Get all client metrics for a load test run. + + Get all client metrics for a load test run. + + :param test_run_id: Unique name of the load test run, must be a valid URL character + ^[a-z0-9_-]*$. Required. + :type test_run_id: str + :param body: Client metrics request model. Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "testRunId": "str", # Optional. Test run name for which client metrics + results is required. + "timeSeries": { + "activeUsers": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + }, + "errors": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + }, + "responseTime": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + }, + "throughput": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + } + } + } + """ + + + @distributed_trace + def get_test_run_client_metrics( + self, + test_run_id: str, + body: Union[JSON, IO], + **kwargs: Any + ) -> JSON: + """Get all client metrics for a load test run. + + Get all client metrics for a load test run. + + :param test_run_id: Unique name of the load test run, must be a valid URL character + ^[a-z0-9_-]*$. Required. + :type test_run_id: str + :param body: Client metrics request model. Is either a model type or a IO type. Required. + :type body: JSON or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "testRunId": "str", # Optional. Test run name for which client metrics + results is required. + "timeSeries": { + "activeUsers": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + }, + "errors": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + }, + "responseTime": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + }, + "throughput": { + "str": [ + { + "timestamp": "2020-02-20 00:00:00", # + Optional. Timestamp(ISO 8601 literal format). + "value": 0.0 # Optional. Value at timestamp. + } + ] + } + } + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + 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 = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = body + + request = build_test_run_get_test_run_client_metrics_request( + test_run_id=test_run_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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + + + @distributed_trace + def get_test_run_client_metrics_filters( + self, + test_run_id: str, + **kwargs: Any + ) -> JSON: + """Get all filters that are supported for client metrics for a given load test run. + + Get all filters that are supported for client metrics for a given load test run. + + :param test_run_id: Unique name for load test run, must be a valid URL character ^[a-z0-9_-]*$. + Required. + :type test_run_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "filters": { + "errorFiltersValues": [ + "str" # Optional. List of errors occurred for the test run, + for which client metrics can be filtered. + ], + "requestSamplerValues": [ + "str" # Optional. List of request sampler for the test run, + for which client metrics can be filtered. + ] + }, + "testRunId": "str", # Optional. Test run name for which client metrics + filters is required. + "timeRange": { + "endTime": "2020-02-20 00:00:00", # Optional. end DateTime(ISO 8601 + literal format) for the requested client metrics filter. + "startTime": "2020-02-20 00:00:00" # Optional. start DateTime(ISO + 8601 literal format) for the requested client metrics filter. + } + } + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', self._config.api_version)) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + + request = build_test_run_get_test_run_client_metrics_filters_request( + test_run_id=test_run_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + + diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/operations/_patch.py b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/operations/_patch.py new file mode 100644 index 000000000000..c3bfcbf81116 --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/operations/_patch.py @@ -0,0 +1,131 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + +from typing import List, cast +from msrest import Serializer +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.rest import HttpRequest +from azure.core.utils import case_insensitive_dict +from .._vendor import _format_url_section +from ._operations import TestOperations as TestOperationsGenerated, JSON, ClsType + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_upload_test_file_request( + test_id: str, + file_id: str, + file_content, + **kwargs, + ) -> HttpRequest: + """ + Core logic for uploading a file + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = "/loadtests/{testId}/files/{fileId}" + path_format_arguments = { + "testId": _SERIALIZER.url("test_id", test_id, 'str', + max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + "fileId": _SERIALIZER.url("file_id", file_id, 'str', + max_length=50, min_length=2, pattern=r'^[a-z0-9_-]*$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + files=file_content, + params=_params, + headers=_headers, + **kwargs + ) + +class TestOperations(TestOperationsGenerated): + """ + for performing the operations on test + """ + def __init__(self, *args, **kwargs): + super(TestOperations, self).__init__(*args, **kwargs) + + def upload_test_file( + self, + test_id: str, + file_id: str, + file_content: JSON, + **kwargs + ) -> JSON: + """ + Uploading a test file + """ + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01-preview")) + cls = kwargs.pop('cls', None) # type: ClsType[JSON] + + _content=file_content + + request = build_upload_test_file_request( + test_id, + file_id, + _content, + api_version=api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + request.method = "PUT" + + pipeline_response = self._client._pipeline.run( #type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) + + return cast(JSON, deserialized) + +__all__: List[str] = ["TestOperations"] +# Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/py.typed b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/azure/analytics/loadtestservice/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/dev_requirements.txt b/sdk/loadtestservice/azure-analytics-loadtestservice/dev_requirements.txt new file mode 100644 index 000000000000..8d3c7d8e1144 --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/dev_requirements.txt @@ -0,0 +1,7 @@ +-e ../../../tools/azure-devtools +-e ../../../tools/azure-sdk-tools +../../core/azure-core +../../identity/azure-identity +aiohttp>=3.0 +typing_extensions>=3.7.2 +asyncio diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/samples/sample.py b/sdk/loadtestservice/azure-analytics-loadtestservice/samples/sample.py new file mode 100644 index 000000000000..5cec20621a5c --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/samples/sample.py @@ -0,0 +1,119 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- +import logging +import os + +from azure.analytics.loadtestservice import LoadTestClient +from azure.identity import DefaultAzureCredential +from azure.core.exceptions import HttpResponseError + +logging.basicConfig(level=logging.DEBUG) +LOG = logging.getLogger() + +# 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, LOADTESTSERVICE_ENDPOINT +try: + endpoint = os.environ["LOADTESTSERVICE_ENDPOINT"] +except KeyError: + LOG.error("Missing environment variable 'LOADTESTSERVICE_ENDPOINT' - please set if before running the example") + exit() + +# Build a client through AAD +client = LoadTestClient(credential=DefaultAzureCredential(), endpoint=endpoint) + +# Creating or updating a load test +try: + test_id="test-name" + body_test={"createdBy": "user-name", # Optional. The user that created the test model. + "createdDateTime": "2022-06-20 00:00:00", # Optional. The created + "description": "test-description", # Optional. The test description. + "displayName": "test-display-name", # Optional. Display name of a test. + "resourceId": "resource-ID", # Optional. + # more param can be there + } + result = client.test.create_or_update_test(test_id, body_test) + print(result) +except HttpResponseError as e: + print('Failed to send JSON message: {}'.format(e.response.json())) + +#Uploading a test file +try: + test_id="test-name" + file_id="file-name" + file_body = {} + #reading file using python open + f= open("jmx-script.jmx","rb") + file_body["file"]=f + result=client.test.upload_test_file(test_id,file_id,file_body) + print(result) +except HttpResponseError as e: + print('Failed to send JSON message: {}'.format(e.response.json())) + +#Creating a test run +try: + test_run_id="test-run-name" + body_test_run=body_test={"createdBy": "user-name", # Optional. The user that created the test model. + "createdDateTime": "2022-06-20 00:00:00", # Optional. The created + "description": "test-description", # Optional. The test description. + "displayName": "test-display-name", # Optional. Display name of a test. + "resourceId": "resource-ID", # Optional. + # more param can be there + } + result=client.test_run.create_and_update_test(test_run_id,body_test_run) + print(result) +except HttpResponseError as e: + print('Failed to send JSON message: {}'.format(e.response.json())) + +# Getting test run client metrics +try: + test_run_id="test-run-name" + body_test_run=body_test={"createdBy": "user-name", # Optional. The user that created the test model. + "createdDateTime": "2022-06-20 00:00:00", # Optional. The created + "description": "test-description", # Optional. The test description. + "displayName": "test-display-name", # Optional. Display name of a test. + "resourceId": "resource-ID", # Optional. + # more param can be there + } + result=client.test_run.get_test_run_client_metrics(test_run_id,body_test_run) + print(result) +except HttpResponseError as e: + print('Failed to send JSON message: {}'.format(e.response.json())) + + +# Stopping a test run +try: + test_run_id="test-run-name" + result=client.test_run.stop_test_run(test_run_id) +except HttpResponseError as e: + print('Failed to send JSON message: {}'.format(e.response.json())) + +# Deleting a load test +try: + test_id="test-name" + result=client.test.delete_load_test(test_id) +except HttpResponseError as e: + print('Failed to send JSON message: {}'.format(e.response.json())) \ No newline at end of file diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/sdk_packaging.toml b/sdk/loadtestservice/azure-analytics-loadtestservice/sdk_packaging.toml new file mode 100644 index 000000000000..94a5cf03a327 --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/sdk_packaging.toml @@ -0,0 +1,6 @@ +[packaging] +package_name = "azure-analytics-loadtestservice" +package_pprint_name = "Azure Analytics LoadTestService" +package_doc_id = "" +is_stable = false +is_arm = false \ No newline at end of file diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/setup.py b/sdk/loadtestservice/azure-analytics-loadtestservice/setup.py new file mode 100644 index 000000000000..f532fb224b23 --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/setup.py @@ -0,0 +1,67 @@ +#!/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 os +import re +from setuptools import setup, find_packages + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-analytics-loadtestservice" +PACKAGE_PPRINT_NAME = "Azure Analytics LoadTestService" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace("-", "/") + +# Version extraction inspired from 'requests' +with open(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") + +setup( + name=PACKAGE_NAME, + version=version, + description="Microsoft {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=open("README.md", "r").read(), + 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/tree/main/sdk/loadtestservice/azure-analytics-loadtestservice", + classifiers=[ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "License :: OSI Approved :: MIT License", + ], + include_package_data=True, + package_data={ + "pytyped": ["py.typed"], + }, + zip_safe=False, + packages=find_packages( + exclude=[ + # Exclude packages that will be covered by PEP420 or nspkg + "azure", + "azure.analytics", + ] + ), + install_requires=[ + "azure-core<2.0.0,>=1.23.0", + "msrest>=0.6.21", + ], + python_requires=">=3.6", +) diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/swagger/README.md b/sdk/loadtestservice/azure-analytics-loadtestservice/swagger/README.md new file mode 100644 index 000000000000..8c889272325d --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/swagger/README.md @@ -0,0 +1,16 @@ +### Settings + +```yaml +input-file: https://github.com/Azure/azure-rest-api-specs/blob/main/specification/loadtestservice/data-plane/Microsoft.LoadTestService/preview/2022-06-01-preview/loadtestservice.json +output-folder: ../azure/analytics/loadtestservice +namespace: azure.analytics.loadtestservice +package-name: azure-analytics-loadtestservice +license-header: MICROSOFT_MIT_NO_VERSION +clear-output-folder: true +no-namespace-folders: true +title: LoadTestClient +version-tolerant: true +package-version: 1.0.0b1 +security: AADToken +security-scopes: https://loadtest.azure-dev.com/.default +``` \ No newline at end of file diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/tests/recordings/test_smoke.test_smoke_create_or_update_test.yaml b/sdk/loadtestservice/azure-analytics-loadtestservice/tests/recordings/test_smoke.test_smoke_create_or_update_test.yaml new file mode 100644 index 000000000000..e03194b9e65e --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/tests/recordings/test_smoke.test_smoke_create_or_update_test.yaml @@ -0,0 +1,54 @@ +interactions: +- request: + body: '{"resourceId": "/subscriptions/123456/resourceGroups/fake/providers/Microsoft.LoadTestService/loadtests/fake", + "testId": "000001", "description": "", "displayName": "test", "loadTestConfig": + {"engineSize": "m", "engineInstances": 1, "splitAllCSVs": false}, "secrets": + {}, "environmentVariables": {}, "passFailCriteria": {"passFailMetrics": {}}, + "keyvaultReferenceIdentityType": "SystemAssigned", "keyvaultReferenceIdentityId": + null}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '432' + Content-Type: + - application/merge-patch+json + User-Agent: + - azsdk-python-analytics-loadtestservice/1.0.0b1 Python/3.9.8 (Windows-10-10.0.19044) + method: PATCH + uri: https://fake.loadtesting.azure.com/loadtests/000001?api-version=2022-06-01-preview + response: + body: + string: '{"testId":"000001","description":"","displayName":"test","resourceId":"/subscriptions/7c71b563-0dc0-4bc0-bcf6-06f8f0516c7a/resourcegroups/yashika-rg/providers/microsoft.loadtestservice/loadtests/loadtestsdk", + "loadTestConfig":{"engineInstances":1,"splitAllCSVs":false},"passFailCriteria":{"passFailMetrics":{}}, + "createdDateTime":"2022-06-21T13:45:51.163Z","createdBy":null,"lastModifiedDateTime":"2022-06-21T13:45:51.163Z", + "lastModifiedBy":null,"inputArtifacts":{"configUrl":null,"testScriptUrl":null,"userPropUrl":null, + "inputArtifactsZipFileurl":null,"additionalUrls":[]},"secrets":null,"environmentVariables":null,"subnetId":null, + "keyvaultReferenceIdentityType":"SystemAssigned","keyvaultReferenceIdentityId":null}' + headers: + api-supported-versions: + - 2021-07-01-preview, 2022-04-15-preview, 2022-06-01-preview + connection: + - keep-alive + content-length: + - '715' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 21 Jun 2022 13:45:51 GMT + location: + - https://fake.loadtesting.azure.com/loadtests/000001?resourceId=%2fsubscriptions%2f7c71b563-0dc0-4bc0-bcf6-06f8f0516c7a%2fresourcegroups%2fyashika-rg%2fproviders%2fmicrosoft.loadtestservice%2floadtests%2floadtestsdk&api-version=2022-06-01-preview + mise-correlation-id: + - 6e963a55-5bfa-4c03-bd4c-e46f96d95709 + strict-transport-security: + - max-age=15724800; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 201 + message: Created +version: 1 \ No newline at end of file diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/tests/recordings/test_smoke.test_smoke_delete_test.yaml b/sdk/loadtestservice/azure-analytics-loadtestservice/tests/recordings/test_smoke.test_smoke_delete_test.yaml new file mode 100644 index 000000000000..1dd9a80b0cae --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/tests/recordings/test_smoke.test_smoke_delete_test.yaml @@ -0,0 +1,36 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-analytics-loadtestservice/1.0.0b1 Python/3.9.8 (Windows-10-10.0.19044) + method: DELETE + uri: https://fake.loadtesting.azure.com/loadtests/000001?api-version=2022-06-01-preview + response: + body: + string: '' + headers: + api-supported-versions: + - 2021-07-01-preview, 2022-04-15-preview, 2022-06-01-preview + connection: + - keep-alive + date: + - Tue, 21 Jun 2022 13:45:51 GMT + mise-correlation-id: + - ade1e246-f549-49eb-8d1a-99432e706c74 + strict-transport-security: + - max-age=15724800; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 204 + message: No Content +version: 1 \ No newline at end of file diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/tests/recordings/test_smoke.test_smoke_list_search.yaml b/sdk/loadtestservice/azure-analytics-loadtestservice/tests/recordings/test_smoke.test_smoke_list_search.yaml new file mode 100644 index 000000000000..b2805a59d68c --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/tests/recordings/test_smoke.test_smoke_list_search.yaml @@ -0,0 +1,38 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-analytics-loadtestservice/1.0.0b1 Python/3.9.8 (Windows-10-10.0.19044) + method: GET + uri: https://fake.loadtesting.azure.com/loadtests/sortAndFilter?maxPageSize=50&api-version=2022-06-01-preview + response: + body: + string: '{"value":[],"nextLink":null}' + headers: + api-supported-versions: + - 2021-07-01-preview, 2022-04-15-preview, 2022-06-01-preview + connection: + - keep-alive + content-length: + - '28' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 21 Jun 2022 13:45:52 GMT + mise-correlation-id: + - d1648cc2-1051-4d86-9ffa-4b036141df7f + strict-transport-security: + - max-age=15724800; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +version: 1 \ No newline at end of file diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/tests/recordings/test_smoke_async.test_smoke_create_or_update_test.yaml b/sdk/loadtestservice/azure-analytics-loadtestservice/tests/recordings/test_smoke_async.test_smoke_create_or_update_test.yaml new file mode 100644 index 000000000000..a8450c9594a5 --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/tests/recordings/test_smoke_async.test_smoke_create_or_update_test.yaml @@ -0,0 +1,42 @@ +interactions: +- request: + body: '{"resourceId": "/subscriptions/123456/resourceGroups/fake/providers/Microsoft.LoadTestService/loadtests/fake", + "testId": "000002", "description": "", "displayName": "test", "loadTestConfig": + {"engineSize": "m", "engineInstances": 1, "splitAllCSVs": false}, "secrets": + {}, "environmentVariables": {}, "passFailCriteria": {"passFailMetrics": {}}, + "keyvaultReferenceIdentityType": "SystemAssigned", "keyvaultReferenceIdentityId": + null}' + headers: + Accept: + - application/json + Content-Length: + - '432' + Content-Type: + - application/merge-patch+json + User-Agent: + - azsdk-python-analytics-loadtestservice/1.0.0b1 Python/3.9.8 (Windows-10-10.0.19044) + method: PATCH + uri: https://fake.loadtesting.azure.com/loadtests/000002?api-version=2022-06-01-preview + response: + body: + string: '{"testId":"000002","description":"","displayName":"test","resourceId":"/subscriptions/7c71b563-0dc0-4bc0-bcf6-06f8f0516c7a/resourcegroups/yashika-rg/providers/microsoft.loadtestservice/loadtests/loadtestsdk", + "loadTestConfig":{"engineInstances":1,"splitAllCSVs":false},"passFailCriteria":{"passFailMetrics":{}}, + "createdDateTime":"2022-06-21T13:45:53.627Z","createdBy":null,"lastModifiedDateTime":"2022-06-21T13:45:53.627Z", + "lastModifiedBy":null,"inputArtifacts":{"configUrl":null,"testScriptUrl":null,"userPropUrl":null, + "inputArtifactsZipFileurl":null,"additionalUrls":[]},"secrets":null,"environmentVariables":null,"subnetId":null, + "keyvaultReferenceIdentityType":"SystemAssigned","keyvaultReferenceIdentityId":null}' + headers: + api-supported-versions: 2021-07-01-preview, 2022-04-15-preview, 2022-06-01-preview + connection: keep-alive + content-length: '715' + content-type: application/json; charset=utf-8 + date: Tue, 21 Jun 2022 13:45:53 GMT + location: https://fake.loadtesting.azure.com/loadtests/000002?resourceId=%2fsubscriptions%2f7c71b563-0dc0-4bc0-bcf6-06f8f0516c7a%2fresourcegroups%2fyashika-rg%2fproviders%2fmicrosoft.loadtestservice%2floadtests%2floadtestsdk&api-version=2022-06-01-preview + mise-correlation-id: 60bab8c6-4f6a-4d88-96c6-87de86c121f4 + strict-transport-security: max-age=15724800; includeSubDomains + x-content-type-options: nosniff + status: + code: 201 + message: Created + url: https://fake.eus.cnt-prod.loadtesting.azure.com/loadtests/000002?api-version=2022-06-01-preview +version: 1 \ No newline at end of file diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/tests/recordings/test_smoke_async.test_smoke_list_search.yaml b/sdk/loadtestservice/azure-analytics-loadtestservice/tests/recordings/test_smoke_async.test_smoke_list_search.yaml new file mode 100644 index 000000000000..441a00b3b8dd --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/tests/recordings/test_smoke_async.test_smoke_list_search.yaml @@ -0,0 +1,32 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-analytics-loadtestservice/1.0.0b1 Python/3.9.8 (Windows-10-10.0.19044) + method: GET + uri: https://fake.loadtesting.azure.com/loadtests/sortAndFilter?maxPageSize=50&api-version=2022-06-01-preview + response: + body: + string: '{"value":[{"testId":"000002","description":"","displayName":"test","resourceId":"/subscriptions/7c71b563-0dc0-4bc0-bcf6-06f8f0516c7a/resourcegroups/yashika-rg/providers/microsoft.loadtestservice/loadtests/loadtestsdk", + "loadTestConfig":{"engineInstances":1,"splitAllCSVs":false},"passFailCriteria":{"passFailMetrics":{}}, + "createdDateTime":"2022-06-21T13:45:53.627Z","createdBy":null,"lastModifiedDateTime":"2022-06-21T13:45:53.627Z", + "lastModifiedBy":null,"inputArtifacts":{"configUrl":null,"testScriptUrl":null,"userPropUrl":null, + "inputArtifactsZipFileurl":null,"additionalUrls":[]},"secrets":null,"environmentVariables":null,"subnetId":null, + "keyvaultReferenceIdentityType":"SystemAssigned","keyvaultReferenceIdentityId":null}],"nextLink":null}' + headers: + api-supported-versions: 2021-07-01-preview, 2022-04-15-preview, 2022-06-01-preview + connection: keep-alive + content-length: '743' + content-type: application/json; charset=utf-8 + date: Tue, 21 Jun 2022 13:45:54 GMT + mise-correlation-id: 26cee0a5-8738-449a-a90b-f926c489c331 + strict-transport-security: max-age=15724800; includeSubDomains + x-content-type-options: nosniff + status: + code: 200 + message: OK + url: https://fake.eus.cnt-prod.loadtesting.azure.com/loadtests/sortAndFilter?maxPageSize=50&api-version=2022-06-01-preview +version: 1 \ No newline at end of file diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/tests/test_smoke.py b/sdk/loadtestservice/azure-analytics-loadtestservice/tests/test_smoke.py new file mode 100644 index 000000000000..c250df876855 --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/tests/test_smoke.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. +# ------------------------------------------------------------------------- +from json import load +from testcase import LoadtestserviceTest, LoadtestservicePowerShellPreparer + +class LoadtestserviceSmokeTest(LoadtestserviceTest): + + @LoadtestservicePowerShellPreparer() + def test_smoke_create_or_update_test(self, loadtestservice_endpoint): + client = self.create_client(loadtestservice_endpoint) + test_id="000001" + body_test={"resourceId":"/subscriptions/123456/resourceGroups/fake/providers/Microsoft.LoadTestService/loadtests/fake", + "testId":"000001","description":"","displayName":"test", + "loadTestConfig":{"engineSize":"m","engineInstances":1,"splitAllCSVs":False},"secrets":{},"environmentVariables":{}, + "passFailCriteria":{"passFailMetrics":{}},"keyvaultReferenceIdentityType":"SystemAssigned","keyvaultReferenceIdentityId":None} + result = client.test.create_or_update_test(test_id, body_test) + assert result is not None + + @LoadtestservicePowerShellPreparer() + def test_smoke_list_search(self, loadtestservice_endpoint): + client = self.create_client(loadtestservice_endpoint) + result = client.test.list_load_test_search() + assert result is not None + + @LoadtestservicePowerShellPreparer() + def test_smoke_delete_test(self, loadtestservice_endpoint): + client = self.create_client(loadtestservice_endpoint) + test_id="000001" + result = client.test.delete_load_test(test_id) + assert result is None \ No newline at end of file diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/tests/test_smoke_async.py b/sdk/loadtestservice/azure-analytics-loadtestservice/tests/test_smoke_async.py new file mode 100644 index 000000000000..fb35b75a2a67 --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/tests/test_smoke_async.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. +# ------------------------------------------------------------------------- +from testcase import LoadtestservicePowerShellPreparer +from testcase_async import LoadtestserviceAsyncTest + + +class LoadtestserviceSmokeAsyncTest(LoadtestserviceAsyncTest): + + @LoadtestservicePowerShellPreparer() + async def test_smoke_create_or_update_test(self, loadtestservice_endpoint): + client = self.create_client(loadtestservice_endpoint) + test_id="000002" + body_test={"resourceId":"/subscriptions/123456/resourceGroups/fake/providers/Microsoft.LoadTestService/loadtests/fake", + "testId":"000002","description":"","displayName":"test", + "loadTestConfig":{"engineSize":"m","engineInstances":1,"splitAllCSVs":False},"secrets":{},"environmentVariables":{}, + "passFailCriteria":{"passFailMetrics":{}},"keyvaultReferenceIdentityType":"SystemAssigned","keyvaultReferenceIdentityId":None} + result = await client.test.create_or_update_test(test_id, body_test) + assert result is not None + + + @LoadtestservicePowerShellPreparer() + async def test_smoke_list_search(self, loadtestservice_endpoint): + client = self.create_client(loadtestservice_endpoint) + result = await client.test.list_load_test_search() + assert result is not None \ No newline at end of file diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/tests/testcase.py b/sdk/loadtestservice/azure-analytics-loadtestservice/tests/testcase.py new file mode 100644 index 000000000000..81cfe4bac820 --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/tests/testcase.py @@ -0,0 +1,27 @@ +# 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. +# -------------------------------------------------------------------------- +import functools +from devtools_testutils import AzureTestCase, PowerShellPreparer +from azure.analytics.loadtestservice import LoadTestClient + +LoadtestservicePowerShellPreparer = functools.partial( + PowerShellPreparer, + "loadtestservice", + loadtestservice_endpoint="https://fake.loadtesting.azure.com", +) + +class LoadtestserviceTest(AzureTestCase): + def __init__(self, method_name, **kwargs): + super(LoadtestserviceTest, self).__init__(method_name, **kwargs) + + def create_client(self, endpoint): + credential = self.get_credential(LoadTestClient) + return self.create_client_from_credential( + LoadTestClient, + credential=credential, + endpoint=endpoint, + ) \ No newline at end of file diff --git a/sdk/loadtestservice/azure-analytics-loadtestservice/tests/testcase_async.py b/sdk/loadtestservice/azure-analytics-loadtestservice/tests/testcase_async.py new file mode 100644 index 000000000000..52f11f5ebd90 --- /dev/null +++ b/sdk/loadtestservice/azure-analytics-loadtestservice/tests/testcase_async.py @@ -0,0 +1,21 @@ +# 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. +# -------------------------------------------------------------------------- +from devtools_testutils import AzureTestCase +from azure.analytics.loadtestservice.aio import LoadTestClient + + +class LoadtestserviceAsyncTest(AzureTestCase): + def __init__(self, method_name, **kwargs): + super(LoadtestserviceAsyncTest, self).__init__(method_name, **kwargs) + + def create_client(self, endpoint): + credential = self.get_credential(LoadTestClient, is_async=True) + return self.create_client_from_credential( + LoadTestClient, + credential=credential, + endpoint=endpoint, + ) \ No newline at end of file diff --git a/sdk/loadtestservice/ci.yml b/sdk/loadtestservice/ci.yml index 171ec2bf8b6f..09f6c14810da 100644 --- a/sdk/loadtestservice/ci.yml +++ b/sdk/loadtestservice/ci.yml @@ -31,3 +31,5 @@ extends: Artifacts: - name: azure-mgmt-loadtestservice safeName: azuremgmtloadtestservice + - name: azure-analytics-loadtestservice + safeName: azureanalyticsloadtestservice diff --git a/shared_requirements.txt b/shared_requirements.txt index ab21127a4818..789429d7fa06 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -221,6 +221,7 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-mixedreality-remoterendering azure-core<2.0.0,>=1.6.0 #override azure-mixedreality-remoterendering azure-mixedreality-authentication>=1.0.0b1 #override azure-ai-language-conversations azure-core<2.0.0,>=1.24.0 +#override azure-analytics-loadtestservice azure-core<2.0.0,>=1.23.0 #override azure-mgmt-eventgrid msrest>=0.6.21 #override azure-ai-language-conversations msrest>=0.6.21 #override azure-mgmt-deviceupdate msrest>=0.6.21