From 88e1579f3def3f0e8b0b9176cae67ebf6a096598 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 3 Mar 2022 20:51:34 +0000 Subject: [PATCH] CodeGen from PR 17034 in Azure/azure-rest-api-specs Merge ba2b1fd0e82c76941fb4d4d14d7202d640d33417 into 6b29b8552671eded065f51ee1b291582ab8cc149 --- .../azure-mgmt-storagecache/_meta.json | 10 +- .../azure/mgmt/storagecache/__init__.py | 9 +- .../azure/mgmt/storagecache/_configuration.py | 21 +- .../azure/mgmt/storagecache/_metadata.json | 26 +- .../azure/mgmt/storagecache/_patch.py | 31 + .../_storage_cache_management_client.py | 110 +- .../azure/mgmt/storagecache/_vendor.py | 27 + .../azure/mgmt/storagecache/_version.py | 2 +- .../azure/mgmt/storagecache/aio/__init__.py | 5 + .../mgmt/storagecache/aio/_configuration.py | 8 +- .../azure/mgmt/storagecache/aio/_patch.py | 31 + .../aio/_storage_cache_management_client.py | 101 +- .../storagecache/aio/operations/__init__.py | 2 + .../operations/_asc_operations_operations.py | 39 +- .../aio/operations/_asc_usages_operations.py | 117 ++ .../aio/operations/_caches_operations.py | 555 +++--- .../aio/operations/_operations.py | 48 +- .../aio/operations/_skus_operations.py | 53 +- .../operations/_storage_target_operations.py | 277 +-- .../operations/_storage_targets_operations.py | 286 ++- .../operations/_usage_models_operations.py | 53 +- .../mgmt/storagecache/models/__init__.py | 147 +- .../azure/mgmt/storagecache/models/_models.py | 1627 ----------------- .../mgmt/storagecache/models/_models_py3.py | 1112 ++++++++--- .../_storage_cache_management_client_enums.py | 47 +- .../mgmt/storagecache/operations/__init__.py | 2 + .../operations/_asc_operations_operations.py | 95 +- .../operations/_asc_usages_operations.py | 151 ++ .../operations/_caches_operations.py | 1120 +++++++----- .../storagecache/operations/_operations.py | 89 +- .../operations/_skus_operations.py | 100 +- .../operations/_storage_target_operations.py | 503 +++-- .../operations/_storage_targets_operations.py | 585 +++--- .../operations/_usage_models_operations.py | 97 +- 34 files changed, 3706 insertions(+), 3780 deletions(-) create mode 100644 sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_patch.py create mode 100644 sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_vendor.py create mode 100644 sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/_patch.py create mode 100644 sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_asc_usages_operations.py delete mode 100644 sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/models/_models.py create mode 100644 sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_asc_usages_operations.py diff --git a/sdk/storage/azure-mgmt-storagecache/_meta.json b/sdk/storage/azure-mgmt-storagecache/_meta.json index 412444d4809aa..60ace06449062 100644 --- a/sdk/storage/azure-mgmt-storagecache/_meta.json +++ b/sdk/storage/azure-mgmt-storagecache/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "21ebd57c7bcf94b51f2d2b94f64ceb140201757b", + "commit": "2b4b00e8bff0d7fc528128a34d5c52bf7863cd00", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/storagecache/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "autorest_command": "autorest specification/storagecache/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/storagecache/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/__init__.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/__init__.py index 12859a199fab0..b265bac8758ec 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/__init__.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['StorageCacheManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_configuration.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_configuration.py index 60b77f200bef2..66d8056d0c5f6 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_configuration.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,20 +33,19 @@ class StorageCacheManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(StorageCacheManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(StorageCacheManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-09-01" + self.api_version = "2022-01-01" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storagecache/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +65,4 @@ def _configure( 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_metadata.json b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_metadata.json index b92eae6592dd3..fcd69e8a5bbbf 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_metadata.json +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_metadata.json @@ -1,17 +1,17 @@ { - "chosen_version": "2021-09-01", - "total_api_version_list": ["2021-09-01"], + "chosen_version": "2022-01-01", + "total_api_version_list": ["2022-01-01"], "client": { "name": "StorageCacheManagementClient", "filename": "_storage_cache_management_client", "description": "A Storage Cache provides scalable caching service for NAS clients, serving data from either NFSv3 or Blob at-rest storage (referred to as \"Storage Targets\"). These operations allow you to manage Caches.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageCacheManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageCacheManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageCacheManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageCacheManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,17 +91,17 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", "skus": "SkusOperations", "usage_models": "UsageModelsOperations", "asc_operations": "AscOperationsOperations", + "asc_usages": "AscUsagesOperations", "caches": "CachesOperations", "storage_targets": "StorageTargetsOperations", "storage_target": "StorageTargetOperations" diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_patch.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_storage_cache_management_client.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_storage_cache_management_client.py index 27e399f3e310a..7de51682fb6cf 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_storage_cache_management_client.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_storage_cache_management_client.py @@ -6,30 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import StorageCacheManagementClientConfiguration +from .operations import AscOperationsOperations, AscUsagesOperations, CachesOperations, Operations, SkusOperations, StorageTargetOperations, StorageTargetsOperations, UsageModelsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import StorageCacheManagementClientConfiguration -from .operations import Operations -from .operations import SkusOperations -from .operations import UsageModelsOperations -from .operations import AscOperationsOperations -from .operations import CachesOperations -from .operations import StorageTargetsOperations -from .operations import StorageTargetOperations -from . import models - -class StorageCacheManagementClient(object): +class StorageCacheManagementClient: """A Storage Cache provides scalable caching service for NAS clients, serving data from either NFSv3 or Blob at-rest storage (referred to as "Storage Targets"). These operations allow you to manage Caches. :ivar operations: Operations operations @@ -40,6 +32,8 @@ class StorageCacheManagementClient(object): :vartype usage_models: storage_cache_management_client.operations.UsageModelsOperations :ivar asc_operations: AscOperationsOperations operations :vartype asc_operations: storage_cache_management_client.operations.AscOperationsOperations + :ivar asc_usages: AscUsagesOperations operations + :vartype asc_usages: storage_cache_management_client.operations.AscUsagesOperations :ivar caches: CachesOperations operations :vartype caches: storage_cache_management_client.operations.CachesOperations :ivar storage_targets: StorageTargetsOperations operations @@ -48,62 +42,64 @@ class StorageCacheManagementClient(object): :vartype storage_target: storage_cache_management_client.operations.StorageTargetOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = StorageCacheManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = StorageCacheManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.usage_models = UsageModelsOperations(self._client, self._config, self._serialize, self._deserialize) + self.asc_operations = AscOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.asc_usages = AscUsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.caches = CachesOperations(self._client, self._config, self._serialize, self._deserialize) + self.storage_targets = StorageTargetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.storage_target = StorageTargetOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.usage_models = UsageModelsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.asc_operations = AscOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.caches = CachesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.storage_targets = StorageTargetsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.storage_target = StorageTargetOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_vendor.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + 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/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_version.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_version.py index 59deb8c7263be..e5754a47ce68f 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_version.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/__init__.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/__init__.py index b1121365385a5..8acb2c057e6d6 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/__init__.py @@ -8,3 +8,8 @@ from ._storage_cache_management_client import StorageCacheManagementClient __all__ = ['StorageCacheManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/_configuration.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/_configuration.py index ca01ad876a4db..404017efd371b 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,15 +37,15 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(StorageCacheManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(StorageCacheManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-09-01" + self.api_version = "2022-01-01" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storagecache/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +64,4 @@ def _configure( 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) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/_patch.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/_storage_cache_management_client.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/_storage_cache_management_client.py index 5ecd23ba3ad72..b05635dc4e33c 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/_storage_cache_management_client.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/_storage_cache_management_client.py @@ -6,28 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import StorageCacheManagementClientConfiguration +from .operations import AscOperationsOperations, AscUsagesOperations, CachesOperations, Operations, SkusOperations, StorageTargetOperations, StorageTargetsOperations, UsageModelsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import StorageCacheManagementClientConfiguration -from .operations import Operations -from .operations import SkusOperations -from .operations import UsageModelsOperations -from .operations import AscOperationsOperations -from .operations import CachesOperations -from .operations import StorageTargetsOperations -from .operations import StorageTargetOperations -from .. import models - - -class StorageCacheManagementClient(object): +class StorageCacheManagementClient: """A Storage Cache provides scalable caching service for NAS clients, serving data from either NFSv3 or Blob at-rest storage (referred to as "Storage Targets"). These operations allow you to manage Caches. :ivar operations: Operations operations @@ -38,68 +32,75 @@ class StorageCacheManagementClient(object): :vartype usage_models: storage_cache_management_client.aio.operations.UsageModelsOperations :ivar asc_operations: AscOperationsOperations operations :vartype asc_operations: storage_cache_management_client.aio.operations.AscOperationsOperations + :ivar asc_usages: AscUsagesOperations operations + :vartype asc_usages: storage_cache_management_client.aio.operations.AscUsagesOperations :ivar caches: CachesOperations operations :vartype caches: storage_cache_management_client.aio.operations.CachesOperations :ivar storage_targets: StorageTargetsOperations operations - :vartype storage_targets: storage_cache_management_client.aio.operations.StorageTargetsOperations + :vartype storage_targets: + storage_cache_management_client.aio.operations.StorageTargetsOperations :ivar storage_target: StorageTargetOperations operations :vartype storage_target: storage_cache_management_client.aio.operations.StorageTargetOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = StorageCacheManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = StorageCacheManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.usage_models = UsageModelsOperations(self._client, self._config, self._serialize, self._deserialize) + self.asc_operations = AscOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.asc_usages = AscUsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.caches = CachesOperations(self._client, self._config, self._serialize, self._deserialize) + self.storage_targets = StorageTargetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.storage_target = StorageTargetOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.usage_models = UsageModelsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.asc_operations = AscOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.caches = CachesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.storage_targets = StorageTargetsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.storage_target = StorageTargetOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/__init__.py index f20bf4cd94a14..9bcdf38cf5116 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/__init__.py @@ -10,6 +10,7 @@ from ._skus_operations import SkusOperations from ._usage_models_operations import UsageModelsOperations from ._asc_operations_operations import AscOperationsOperations +from ._asc_usages_operations import AscUsagesOperations from ._caches_operations import CachesOperations from ._storage_targets_operations import StorageTargetsOperations from ._storage_target_operations import StorageTargetOperations @@ -19,6 +20,7 @@ 'SkusOperations', 'UsageModelsOperations', 'AscOperationsOperations', + 'AscUsagesOperations', 'CachesOperations', 'StorageTargetsOperations', 'StorageTargetOperations', diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_asc_operations_operations.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_asc_operations_operations.py index b92ff67d68ab1..9fc1105af4e7e 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_asc_operations_operations.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_asc_operations_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._asc_operations_operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, location: str, @@ -62,27 +67,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'location': self._serialize.url("location", location, 'str'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + location=location, + operation_id=operation_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -96,4 +91,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/locations/{location}/ascOperations/{operationId}'} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_asc_usages_operations.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_asc_usages_operations.py new file mode 100644 index 0000000000000..4e66c4c2b9604 --- /dev/null +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_asc_usages_operations.py @@ -0,0 +1,117 @@ +# 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._asc_usages_operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AscUsagesOperations: + """AscUsagesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~storage_cache_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + location: str, + **kwargs: Any + ) -> AsyncIterable["_models.ResourceUsagesListResult"]: + """Gets the quantity used and quota limit for resources. + + :param location: The name of the region to query for usage information. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceUsagesListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~storage_cache_management_client.models.ResourceUsagesListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUsagesListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ResourceUsagesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/locations/{location}/usages'} # type: ignore diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_caches_operations.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_caches_operations.py index a766d890303ca..7798f541f891e 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_caches_operations.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_caches_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._caches_operations import build_create_or_update_request_initial, build_debug_info_request_initial, build_delete_request_initial, build_flush_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_start_request_initial, build_stop_request_initial, build_update_request, build_upgrade_firmware_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -51,7 +57,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CachesListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~storage_cache_management_client.models.CachesListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~storage_cache_management_client.models.CachesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.CachesListResult"] @@ -59,34 +66,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('CachesListResult', pipeline_response) + deserialized = self._deserialize("CachesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -104,11 +106,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/caches'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -120,7 +124,8 @@ def list_by_resource_group( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CachesListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~storage_cache_management_client.models.CachesListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~storage_cache_management_client.models.CachesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.CachesListResult"] @@ -128,35 +133,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('CachesListResult', pipeline_response) + deserialized = self._deserialize("CachesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -174,6 +175,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -190,27 +192,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + cache_name=cache_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -223,6 +215,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -238,15 +232,17 @@ async def begin_delete( :type cache_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -260,21 +256,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -286,8 +275,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -311,27 +302,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + cache_name=cache_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -345,8 +326,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -359,35 +342,25 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if cache is not None: - body_content = self._serialize.body(cache, 'Cache') + _json = self._serialize.body(cache, 'Cache') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -406,8 +379,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -427,15 +403,18 @@ async def begin_create_or_update( :type cache: ~storage_cache_management_client.models.Cache :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Cache or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~storage_cache_management_client.models.Cache] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Cache"] lro_delay = kwargs.pop( 'polling_interval', @@ -447,27 +426,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, cache_name=cache_name, cache=cache, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Cache', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -479,8 +452,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} # type: ignore + @distributed_trace_async async def update( self, resource_group_name: str, @@ -508,35 +483,25 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if cache is not None: - body_content = self._serialize.body(cache, 'Cache') + _json = self._serialize.body(cache, 'Cache') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -550,8 +515,10 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} # type: ignore + async def _debug_info_initial( self, resource_group_name: str, @@ -563,27 +530,17 @@ async def _debug_info_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self._debug_info_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_debug_info_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + template_url=self._debug_info_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -596,6 +553,8 @@ async def _debug_info_initial( _debug_info_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/debugInfo'} # type: ignore + + @distributed_trace_async async def begin_debug_info( self, resource_group_name: str, @@ -611,15 +570,17 @@ async def begin_debug_info( :type cache_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -633,21 +594,14 @@ async def begin_debug_info( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -659,6 +613,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_debug_info.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/debugInfo'} # type: ignore async def _flush_initial( @@ -672,27 +627,17 @@ async def _flush_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self._flush_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_flush_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + template_url=self._flush_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -705,6 +650,8 @@ async def _flush_initial( _flush_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/flush'} # type: ignore + + @distributed_trace_async async def begin_flush( self, resource_group_name: str, @@ -721,15 +668,17 @@ async def begin_flush( :type cache_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -743,21 +692,14 @@ async def begin_flush( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -769,6 +711,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_flush.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/flush'} # type: ignore async def _start_initial( @@ -782,27 +725,17 @@ async def _start_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self._start_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_start_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + template_url=self._start_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -815,6 +748,8 @@ async def _start_initial( _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/start'} # type: ignore + + @distributed_trace_async async def begin_start( self, resource_group_name: str, @@ -830,15 +765,17 @@ async def begin_start( :type cache_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -852,21 +789,14 @@ async def begin_start( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -878,6 +808,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/start'} # type: ignore async def _stop_initial( @@ -891,27 +822,17 @@ async def _stop_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self._stop_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_stop_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + template_url=self._stop_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -924,6 +845,8 @@ async def _stop_initial( _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/stop'} # type: ignore + + @distributed_trace_async async def begin_stop( self, resource_group_name: str, @@ -939,15 +862,17 @@ async def begin_stop( :type cache_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -961,21 +886,14 @@ async def begin_stop( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -987,6 +905,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/stop'} # type: ignore async def _upgrade_firmware_initial( @@ -1000,27 +919,17 @@ async def _upgrade_firmware_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self._upgrade_firmware_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_upgrade_firmware_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + template_url=self._upgrade_firmware_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1033,6 +942,8 @@ async def _upgrade_firmware_initial( _upgrade_firmware_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/upgrade'} # type: ignore + + @distributed_trace_async async def begin_upgrade_firmware( self, resource_group_name: str, @@ -1049,15 +960,17 @@ async def begin_upgrade_firmware( :type cache_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1071,21 +984,14 @@ async def begin_upgrade_firmware( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1097,4 +1003,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_upgrade_firmware.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/upgrade'} # type: ignore diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_operations.py index ae89eb1912399..bc85dfb0c674c 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -48,8 +54,10 @@ def list( """Lists all of the available Resource Provider operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiOperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~storage_cache_management_client.models.ApiOperationListResult] + :return: An iterator like instance of either ApiOperationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~storage_cache_management_client.models.ApiOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiOperationListResult"] @@ -57,30 +65,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApiOperationListResult', pipeline_response) + deserialized = self._deserialize("ApiOperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +103,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_skus_operations.py index 52504304edf96..31f0d09282ec0 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_skus_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._skus_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceSkusResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~storage_cache_management_client.models.ResourceSkusResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~storage_cache_management_client.models.ResourceSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkusResult"] @@ -57,34 +64,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ResourceSkusResult', pipeline_response) + deserialized = self._deserialize("ResourceSkusResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,6 +104,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_storage_target_operations.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_storage_target_operations.py index 09cb276b9ba88..dcf0be5402b84 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_storage_target_operations.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_storage_target_operations.py @@ -5,18 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._storage_target_operations import build_flush_request_initial, build_invalidate_request_initial, build_resume_request_initial, build_suspend_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,28 +58,18 @@ async def _flush_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self._flush_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_flush_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + storage_target_name=storage_target_name, + template_url=self._flush_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -88,6 +82,8 @@ async def _flush_initial( _flush_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/flush'} # type: ignore + + @distributed_trace_async async def begin_flush( self, resource_group_name: str, @@ -108,15 +104,17 @@ async def begin_flush( :type storage_target_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -131,22 +129,14 @@ async def begin_flush( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -158,6 +148,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_flush.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/flush'} # type: ignore async def _suspend_initial( @@ -172,28 +163,18 @@ async def _suspend_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self._suspend_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_suspend_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + storage_target_name=storage_target_name, + template_url=self._suspend_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -206,6 +187,8 @@ async def _suspend_initial( _suspend_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/suspend'} # type: ignore + + @distributed_trace_async async def begin_suspend( self, resource_group_name: str, @@ -224,15 +207,17 @@ async def begin_suspend( :type storage_target_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -247,22 +232,14 @@ async def begin_suspend( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -274,6 +251,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_suspend.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/suspend'} # type: ignore async def _resume_initial( @@ -288,28 +266,18 @@ async def _resume_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self._resume_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_resume_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + storage_target_name=storage_target_name, + template_url=self._resume_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -322,6 +290,8 @@ async def _resume_initial( _resume_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/resume'} # type: ignore + + @distributed_trace_async async def begin_resume( self, resource_group_name: str, @@ -340,15 +310,17 @@ async def begin_resume( :type storage_target_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -363,22 +335,14 @@ async def begin_resume( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -390,4 +354,109 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_resume.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/resume'} # type: ignore + + async def _invalidate_initial( + self, + resource_group_name: str, + cache_name: str, + storage_target_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_invalidate_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + storage_target_name=storage_target_name, + template_url=self._invalidate_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _invalidate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/invalidate'} # type: ignore + + + @distributed_trace_async + async def begin_invalidate( + self, + resource_group_name: str, + cache_name: str, + storage_target_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Invalidate all cached data for a storage target. Cached files are discarded and fetched from + the back end on the next request. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must not be greater than 80 and chars must be + from the [-0-9a-zA-Z_] char class. + :type cache_name: str + :param storage_target_name: Name of Storage Target. + :type storage_target_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._invalidate_initial( + resource_group_name=resource_group_name, + cache_name=cache_name, + storage_target_name=storage_target_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_invalidate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/invalidate'} # type: ignore diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_storage_targets_operations.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_storage_targets_operations.py index 69294603a06db..cd67d08304a2a 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_storage_targets_operations.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_storage_targets_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._storage_targets_operations import build_create_or_update_request_initial, build_delete_request_initial, build_dns_refresh_request_initial, build_get_request, build_list_by_cache_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,28 +60,18 @@ async def _dns_refresh_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self._dns_refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_dns_refresh_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + storage_target_name=storage_target_name, + template_url=self._dns_refresh_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -89,6 +84,8 @@ async def _dns_refresh_initial( _dns_refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/dnsRefresh'} # type: ignore + + @distributed_trace_async async def begin_dns_refresh( self, resource_group_name: str, @@ -107,15 +104,17 @@ async def begin_dns_refresh( :type storage_target_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -130,22 +129,14 @@ async def begin_dns_refresh( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -157,8 +148,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_dns_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/dnsRefresh'} # type: ignore + @distributed_trace def list_by_cache( self, resource_group_name: str, @@ -173,8 +166,10 @@ def list_by_cache( from the [-0-9a-zA-Z_] char class. :type cache_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageTargetsResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~storage_cache_management_client.models.StorageTargetsResult] + :return: An iterator like instance of either StorageTargetsResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~storage_cache_management_client.models.StorageTargetsResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageTargetsResult"] @@ -182,36 +177,33 @@ def list_by_cache( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_cache.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_cache_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + template_url=self.list_by_cache.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_cache_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('StorageTargetsResult', pipeline_response) + deserialized = self._deserialize("StorageTargetsResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -229,6 +221,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -247,30 +240,19 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + storage_target_name=storage_target_name, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -283,6 +265,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -308,15 +292,17 @@ async def begin_delete( :type force: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -332,22 +318,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -359,8 +337,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -387,28 +367,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + storage_target_name=storage_target_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -422,8 +392,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -437,36 +409,26 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if storagetarget is not None: - body_content = self._serialize.body(storagetarget, 'StorageTarget') + _json = self._serialize.body(storagetarget, 'StorageTarget') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + storage_target_name=storage_target_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -485,8 +447,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -510,15 +475,20 @@ async def begin_create_or_update( :type storagetarget: ~storage_cache_management_client.models.StorageTarget :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either StorageTarget or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~storage_cache_management_client.models.StorageTarget] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageTarget or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~storage_cache_management_client.models.StorageTarget] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageTarget"] lro_delay = kwargs.pop( 'polling_interval', @@ -531,28 +501,21 @@ async def begin_create_or_update( cache_name=cache_name, storage_target_name=storage_target_name, storagetarget=storagetarget, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('StorageTarget', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -564,4 +527,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}'} # type: ignore diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_usage_models_operations.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_usage_models_operations.py index f911ccab46604..1f3147c22440e 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_usage_models_operations.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_usage_models_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._usage_models_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either UsageModelsResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~storage_cache_management_client.models.UsageModelsResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~storage_cache_management_client.models.UsageModelsResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageModelsResult"] @@ -57,34 +64,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('UsageModelsResult', pipeline_response) + deserialized = self._deserialize("UsageModelsResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,6 +104,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/models/__init__.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/models/__init__.py index c9d72405a55a6..c17a790454f71 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/models/__init__.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/models/__init__.py @@ -6,100 +6,56 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ApiOperation - from ._models_py3 import ApiOperationDisplay - from ._models_py3 import ApiOperationListResult - from ._models_py3 import ApiOperationPropertiesServiceSpecification - from ._models_py3 import AscOperation - from ._models_py3 import BlobNfsTarget - from ._models_py3 import Cache - from ._models_py3 import CacheActiveDirectorySettings - from ._models_py3 import CacheActiveDirectorySettingsCredentials - from ._models_py3 import CacheDirectorySettings - from ._models_py3 import CacheEncryptionSettings - from ._models_py3 import CacheHealth - from ._models_py3 import CacheIdentity - from ._models_py3 import CacheNetworkSettings - from ._models_py3 import CacheSecuritySettings - from ._models_py3 import CacheSku - from ._models_py3 import CacheUpgradeStatus - from ._models_py3 import CacheUsernameDownloadSettings - from ._models_py3 import CacheUsernameDownloadSettingsCredentials - from ._models_py3 import CachesListResult - from ._models_py3 import ClfsTarget - from ._models_py3 import CloudErrorBody - from ._models_py3 import Condition - from ._models_py3 import ErrorResponse - from ._models_py3 import KeyVaultKeyReference - from ._models_py3 import KeyVaultKeyReferenceSourceVault - from ._models_py3 import MetricDimension - from ._models_py3 import MetricSpecification - from ._models_py3 import NamespaceJunction - from ._models_py3 import Nfs3Target - from ._models_py3 import NfsAccessPolicy - from ._models_py3 import NfsAccessRule - from ._models_py3 import ResourceSku - from ._models_py3 import ResourceSkuCapabilities - from ._models_py3 import ResourceSkuLocationInfo - from ._models_py3 import ResourceSkusResult - from ._models_py3 import Restriction - from ._models_py3 import StorageTarget - from ._models_py3 import StorageTargetResource - from ._models_py3 import StorageTargetsResult - from ._models_py3 import SystemData - from ._models_py3 import UnknownTarget - from ._models_py3 import UsageModel - from ._models_py3 import UsageModelDisplay - from ._models_py3 import UsageModelsResult - from ._models_py3 import UserAssignedIdentitiesValue -except (SyntaxError, ImportError): - from ._models import ApiOperation # type: ignore - from ._models import ApiOperationDisplay # type: ignore - from ._models import ApiOperationListResult # type: ignore - from ._models import ApiOperationPropertiesServiceSpecification # type: ignore - from ._models import AscOperation # type: ignore - from ._models import BlobNfsTarget # type: ignore - from ._models import Cache # type: ignore - from ._models import CacheActiveDirectorySettings # type: ignore - from ._models import CacheActiveDirectorySettingsCredentials # type: ignore - from ._models import CacheDirectorySettings # type: ignore - from ._models import CacheEncryptionSettings # type: ignore - from ._models import CacheHealth # type: ignore - from ._models import CacheIdentity # type: ignore - from ._models import CacheNetworkSettings # type: ignore - from ._models import CacheSecuritySettings # type: ignore - from ._models import CacheSku # type: ignore - from ._models import CacheUpgradeStatus # type: ignore - from ._models import CacheUsernameDownloadSettings # type: ignore - from ._models import CacheUsernameDownloadSettingsCredentials # type: ignore - from ._models import CachesListResult # type: ignore - from ._models import ClfsTarget # type: ignore - from ._models import CloudErrorBody # type: ignore - from ._models import Condition # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import KeyVaultKeyReference # type: ignore - from ._models import KeyVaultKeyReferenceSourceVault # type: ignore - from ._models import MetricDimension # type: ignore - from ._models import MetricSpecification # type: ignore - from ._models import NamespaceJunction # type: ignore - from ._models import Nfs3Target # type: ignore - from ._models import NfsAccessPolicy # type: ignore - from ._models import NfsAccessRule # type: ignore - from ._models import ResourceSku # type: ignore - from ._models import ResourceSkuCapabilities # type: ignore - from ._models import ResourceSkuLocationInfo # type: ignore - from ._models import ResourceSkusResult # type: ignore - from ._models import Restriction # type: ignore - from ._models import StorageTarget # type: ignore - from ._models import StorageTargetResource # type: ignore - from ._models import StorageTargetsResult # type: ignore - from ._models import SystemData # type: ignore - from ._models import UnknownTarget # type: ignore - from ._models import UsageModel # type: ignore - from ._models import UsageModelDisplay # type: ignore - from ._models import UsageModelsResult # type: ignore - from ._models import UserAssignedIdentitiesValue # type: ignore +from ._models_py3 import ApiOperation +from ._models_py3 import ApiOperationDisplay +from ._models_py3 import ApiOperationListResult +from ._models_py3 import ApiOperationPropertiesServiceSpecification +from ._models_py3 import AscOperation +from ._models_py3 import BlobNfsTarget +from ._models_py3 import Cache +from ._models_py3 import CacheActiveDirectorySettings +from ._models_py3 import CacheActiveDirectorySettingsCredentials +from ._models_py3 import CacheDirectorySettings +from ._models_py3 import CacheEncryptionSettings +from ._models_py3 import CacheHealth +from ._models_py3 import CacheIdentity +from ._models_py3 import CacheNetworkSettings +from ._models_py3 import CacheSecuritySettings +from ._models_py3 import CacheSku +from ._models_py3 import CacheUpgradeStatus +from ._models_py3 import CacheUsernameDownloadSettings +from ._models_py3 import CacheUsernameDownloadSettingsCredentials +from ._models_py3 import CachesListResult +from ._models_py3 import ClfsTarget +from ._models_py3 import CloudErrorBody +from ._models_py3 import Condition +from ._models_py3 import ErrorResponse +from ._models_py3 import KeyVaultKeyReference +from ._models_py3 import KeyVaultKeyReferenceSourceVault +from ._models_py3 import MetricDimension +from ._models_py3 import MetricSpecification +from ._models_py3 import NamespaceJunction +from ._models_py3 import Nfs3Target +from ._models_py3 import NfsAccessPolicy +from ._models_py3 import NfsAccessRule +from ._models_py3 import ResourceSku +from ._models_py3 import ResourceSkuCapabilities +from ._models_py3 import ResourceSkuLocationInfo +from ._models_py3 import ResourceSkusResult +from ._models_py3 import ResourceUsage +from ._models_py3 import ResourceUsageName +from ._models_py3 import ResourceUsagesListResult +from ._models_py3 import Restriction +from ._models_py3 import StorageTarget +from ._models_py3 import StorageTargetResource +from ._models_py3 import StorageTargetsResult +from ._models_py3 import SystemData +from ._models_py3 import UnknownTarget +from ._models_py3 import UsageModel +from ._models_py3 import UsageModelDisplay +from ._models_py3 import UsageModelsResult +from ._models_py3 import UserAssignedIdentitiesValue + from ._storage_cache_management_client_enums import ( CacheIdentityType, @@ -155,6 +111,9 @@ 'ResourceSkuCapabilities', 'ResourceSkuLocationInfo', 'ResourceSkusResult', + 'ResourceUsage', + 'ResourceUsageName', + 'ResourceUsagesListResult', 'Restriction', 'StorageTarget', 'StorageTargetResource', diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/models/_models.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/models/_models.py deleted file mode 100644 index 2b21dd305e289..0000000000000 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/models/_models.py +++ /dev/null @@ -1,1627 +0,0 @@ -# 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 msrest.serialization - - -class ApiOperation(msrest.serialization.Model): - """REST API operation description: see https://github.com/Azure/azure-rest-api-specs/blob/master/documentation/openapi-authoring-automated-guidelines.md#r3023-operationsapiimplementation. - - :param display: The object that represents the operation. - :type display: ~storage_cache_management_client.models.ApiOperationDisplay - :param origin: Origin of the operation. - :type origin: str - :param is_data_action: The flag that indicates whether the operation applies to data plane. - :type is_data_action: bool - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param service_specification: Specification of the all the metrics provided for a resource - type. - :type service_specification: - ~storage_cache_management_client.models.ApiOperationPropertiesServiceSpecification - """ - - _attribute_map = { - 'display': {'key': 'display', 'type': 'ApiOperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ApiOperationPropertiesServiceSpecification'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiOperation, self).__init__(**kwargs) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - self.is_data_action = kwargs.get('is_data_action', None) - self.name = kwargs.get('name', None) - self.service_specification = kwargs.get('service_specification', None) - - -class ApiOperationDisplay(msrest.serialization.Model): - """The object that represents the operation. - - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param provider: Service provider: Microsoft.StorageCache. - :type provider: str - :param resource: Resource on which the operation is performed: Cache, etc. - :type resource: str - :param description: The description of the operation. - :type description: str - """ - - _attribute_map = { - 'operation': {'key': 'operation', 'type': 'str'}, - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiOperationDisplay, self).__init__(**kwargs) - self.operation = kwargs.get('operation', None) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.description = kwargs.get('description', None) - - -class ApiOperationListResult(msrest.serialization.Model): - """Result of the request to list Resource Provider operations. It contains a list of operations and a URL link to get the next set of results. - - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str - :param value: List of Resource Provider operations supported by the Microsoft.StorageCache - resource provider. - :type value: list[~storage_cache_management_client.models.ApiOperation] - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[ApiOperation]'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiOperationListResult, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs.get('value', None) - - -class ApiOperationPropertiesServiceSpecification(msrest.serialization.Model): - """Specification of the all the metrics provided for a resource type. - - :param metric_specifications: Details about operations related to metrics. - :type metric_specifications: list[~storage_cache_management_client.models.MetricSpecification] - """ - - _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiOperationPropertiesServiceSpecification, self).__init__(**kwargs) - self.metric_specifications = kwargs.get('metric_specifications', None) - - -class AscOperation(msrest.serialization.Model): - """The status of operation. - - :param id: The operation Id. - :type id: str - :param name: The operation name. - :type name: str - :param start_time: The start time of the operation. - :type start_time: str - :param end_time: The end time of the operation. - :type end_time: str - :param status: The status of the operation. - :type status: str - :param error: The error detail of the operation if any. - :type error: ~storage_cache_management_client.models.ErrorResponse - :param output: Additional operation-specific output. - :type output: dict[str, any] - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'str'}, - 'end_time': {'key': 'endTime', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - 'output': {'key': 'properties.output', 'type': '{object}'}, - } - - def __init__( - self, - **kwargs - ): - super(AscOperation, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.start_time = kwargs.get('start_time', None) - self.end_time = kwargs.get('end_time', None) - self.status = kwargs.get('status', None) - self.error = kwargs.get('error', None) - self.output = kwargs.get('output', None) - - -class BlobNfsTarget(msrest.serialization.Model): - """Properties pertaining to the BlobNfsTarget. - - :param target: Resource ID of the storage container. - :type target: str - :param usage_model: Identifies the StorageCache usage model to be used for this storage target. - :type usage_model: str - """ - - _attribute_map = { - 'target': {'key': 'target', 'type': 'str'}, - 'usage_model': {'key': 'usageModel', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BlobNfsTarget, self).__init__(**kwargs) - self.target = kwargs.get('target', None) - self.usage_model = kwargs.get('usage_model', None) - - -class Cache(msrest.serialization.Model): - """A Cache instance. Follows Azure Resource Manager standards: https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/resource-api-reference.md. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :ivar id: Resource ID of the Cache. - :vartype id: str - :param location: Region name string. - :type location: str - :ivar name: Name of Cache. - :vartype name: str - :ivar type: Type of the Cache; Microsoft.StorageCache/Cache. - :vartype type: str - :param identity: The identity of the cache, if configured. - :type identity: ~storage_cache_management_client.models.CacheIdentity - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~storage_cache_management_client.models.SystemData - :param sku: SKU for the Cache. - :type sku: ~storage_cache_management_client.models.CacheSku - :param cache_size_gb: The size of this Cache, in GB. - :type cache_size_gb: int - :ivar health: Health of the Cache. - :vartype health: ~storage_cache_management_client.models.CacheHealth - :ivar mount_addresses: Array of IP addresses that can be used by clients mounting this Cache. - :vartype mount_addresses: list[str] - :ivar provisioning_state: ARM provisioning state, see - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. - Possible values include: "Succeeded", "Failed", "Cancelled", "Creating", "Deleting", - "Updating". - :vartype provisioning_state: str or - ~storage_cache_management_client.models.ProvisioningStateType - :param subnet: Subnet used for the Cache. - :type subnet: str - :ivar upgrade_status: Upgrade status of the Cache. - :vartype upgrade_status: ~storage_cache_management_client.models.CacheUpgradeStatus - :param network_settings: Specifies network settings of the cache. - :type network_settings: ~storage_cache_management_client.models.CacheNetworkSettings - :param encryption_settings: Specifies encryption settings of the cache. - :type encryption_settings: ~storage_cache_management_client.models.CacheEncryptionSettings - :param security_settings: Specifies security settings of the cache. - :type security_settings: ~storage_cache_management_client.models.CacheSecuritySettings - :param directory_services_settings: Specifies Directory Services settings of the cache. - :type directory_services_settings: - ~storage_cache_management_client.models.CacheDirectorySettings - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^[-0-9a-zA-Z_]{1,80}$'}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'health': {'readonly': True}, - 'mount_addresses': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'upgrade_status': {'readonly': True}, - } - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'id': {'key': 'id', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'CacheIdentity'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'sku': {'key': 'sku', 'type': 'CacheSku'}, - 'cache_size_gb': {'key': 'properties.cacheSizeGB', 'type': 'int'}, - 'health': {'key': 'properties.health', 'type': 'CacheHealth'}, - 'mount_addresses': {'key': 'properties.mountAddresses', 'type': '[str]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'subnet': {'key': 'properties.subnet', 'type': 'str'}, - 'upgrade_status': {'key': 'properties.upgradeStatus', 'type': 'CacheUpgradeStatus'}, - 'network_settings': {'key': 'properties.networkSettings', 'type': 'CacheNetworkSettings'}, - 'encryption_settings': {'key': 'properties.encryptionSettings', 'type': 'CacheEncryptionSettings'}, - 'security_settings': {'key': 'properties.securitySettings', 'type': 'CacheSecuritySettings'}, - 'directory_services_settings': {'key': 'properties.directoryServicesSettings', 'type': 'CacheDirectorySettings'}, - } - - def __init__( - self, - **kwargs - ): - super(Cache, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.id = None - self.location = kwargs.get('location', None) - self.name = None - self.type = None - self.identity = kwargs.get('identity', None) - self.system_data = None - self.sku = kwargs.get('sku', None) - self.cache_size_gb = kwargs.get('cache_size_gb', None) - self.health = None - self.mount_addresses = None - self.provisioning_state = None - self.subnet = kwargs.get('subnet', None) - self.upgrade_status = None - self.network_settings = kwargs.get('network_settings', None) - self.encryption_settings = kwargs.get('encryption_settings', None) - self.security_settings = kwargs.get('security_settings', None) - self.directory_services_settings = kwargs.get('directory_services_settings', None) - - -class CacheActiveDirectorySettings(msrest.serialization.Model): - """Active Directory settings used to join a cache to a domain. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param primary_dns_ip_address: Required. Primary DNS IP address used to resolve the Active - Directory domain controller's fully qualified domain name. - :type primary_dns_ip_address: str - :param secondary_dns_ip_address: Secondary DNS IP address used to resolve the Active Directory - domain controller's fully qualified domain name. - :type secondary_dns_ip_address: str - :param domain_name: Required. The fully qualified domain name of the Active Directory domain - controller. - :type domain_name: str - :param domain_net_bios_name: Required. The Active Directory domain's NetBIOS name. - :type domain_net_bios_name: str - :param cache_net_bios_name: Required. The NetBIOS name to assign to the HPC Cache when it joins - the Active Directory domain as a server. Length must 1-15 characters from the class - [-0-9a-zA-Z]. - :type cache_net_bios_name: str - :ivar domain_joined: True if the HPC Cache is joined to the Active Directory domain. Possible - values include: "Yes", "No", "Error". - :vartype domain_joined: str or ~storage_cache_management_client.models.DomainJoinedType - :param credentials: Active Directory admin credentials used to join the HPC Cache to a domain. - :type credentials: - ~storage_cache_management_client.models.CacheActiveDirectorySettingsCredentials - """ - - _validation = { - 'primary_dns_ip_address': {'required': True}, - 'domain_name': {'required': True}, - 'domain_net_bios_name': {'required': True}, - 'cache_net_bios_name': {'required': True, 'pattern': r'^[-0-9a-zA-Z]{1,15}$'}, - 'domain_joined': {'readonly': True}, - } - - _attribute_map = { - 'primary_dns_ip_address': {'key': 'primaryDnsIpAddress', 'type': 'str'}, - 'secondary_dns_ip_address': {'key': 'secondaryDnsIpAddress', 'type': 'str'}, - 'domain_name': {'key': 'domainName', 'type': 'str'}, - 'domain_net_bios_name': {'key': 'domainNetBiosName', 'type': 'str'}, - 'cache_net_bios_name': {'key': 'cacheNetBiosName', 'type': 'str'}, - 'domain_joined': {'key': 'domainJoined', 'type': 'str'}, - 'credentials': {'key': 'credentials', 'type': 'CacheActiveDirectorySettingsCredentials'}, - } - - def __init__( - self, - **kwargs - ): - super(CacheActiveDirectorySettings, self).__init__(**kwargs) - self.primary_dns_ip_address = kwargs['primary_dns_ip_address'] - self.secondary_dns_ip_address = kwargs.get('secondary_dns_ip_address', None) - self.domain_name = kwargs['domain_name'] - self.domain_net_bios_name = kwargs['domain_net_bios_name'] - self.cache_net_bios_name = kwargs['cache_net_bios_name'] - self.domain_joined = None - self.credentials = kwargs.get('credentials', None) - - -class CacheActiveDirectorySettingsCredentials(msrest.serialization.Model): - """Active Directory admin credentials used to join the HPC Cache to a domain. - - All required parameters must be populated in order to send to Azure. - - :param username: Required. Username of the Active Directory domain administrator. This value is - stored encrypted and not returned on response. - :type username: str - :param password: Required. Plain text password of the Active Directory domain administrator. - This value is stored encrypted and not returned on response. - :type password: str - """ - - _validation = { - 'username': {'required': True}, - 'password': {'required': True}, - } - - _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CacheActiveDirectorySettingsCredentials, self).__init__(**kwargs) - self.username = kwargs['username'] - self.password = kwargs['password'] - - -class CacheDirectorySettings(msrest.serialization.Model): - """Cache Directory Services settings. - - :param active_directory: Specifies settings for joining the HPC Cache to an Active Directory - domain. - :type active_directory: ~storage_cache_management_client.models.CacheActiveDirectorySettings - :param username_download: Specifies settings for Extended Groups. Extended Groups allows users - to be members of more than 16 groups. - :type username_download: ~storage_cache_management_client.models.CacheUsernameDownloadSettings - """ - - _attribute_map = { - 'active_directory': {'key': 'activeDirectory', 'type': 'CacheActiveDirectorySettings'}, - 'username_download': {'key': 'usernameDownload', 'type': 'CacheUsernameDownloadSettings'}, - } - - def __init__( - self, - **kwargs - ): - super(CacheDirectorySettings, self).__init__(**kwargs) - self.active_directory = kwargs.get('active_directory', None) - self.username_download = kwargs.get('username_download', None) - - -class CacheEncryptionSettings(msrest.serialization.Model): - """Cache encryption settings. - - :param key_encryption_key: Specifies the location of the key encryption key in Key Vault. - :type key_encryption_key: ~storage_cache_management_client.models.KeyVaultKeyReference - :param rotation_to_latest_key_version_enabled: Specifies whether the service will automatically - rotate to the newest version of the key in the Key Vault. - :type rotation_to_latest_key_version_enabled: bool - """ - - _attribute_map = { - 'key_encryption_key': {'key': 'keyEncryptionKey', 'type': 'KeyVaultKeyReference'}, - 'rotation_to_latest_key_version_enabled': {'key': 'rotationToLatestKeyVersionEnabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(CacheEncryptionSettings, self).__init__(**kwargs) - self.key_encryption_key = kwargs.get('key_encryption_key', None) - self.rotation_to_latest_key_version_enabled = kwargs.get('rotation_to_latest_key_version_enabled', None) - - -class CacheHealth(msrest.serialization.Model): - """An indication of Cache health. Gives more information about health than just that related to provisioning. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param state: List of Cache health states. Possible values include: "Unknown", "Healthy", - "Degraded", "Down", "Transitioning", "Stopping", "Stopped", "Upgrading", "Flushing". - :type state: str or ~storage_cache_management_client.models.HealthStateType - :param status_description: Describes explanation of state. - :type status_description: str - :ivar conditions: Outstanding conditions that need to be investigated and resolved. - :vartype conditions: list[~storage_cache_management_client.models.Condition] - """ - - _validation = { - 'conditions': {'readonly': True}, - } - - _attribute_map = { - 'state': {'key': 'state', 'type': 'str'}, - 'status_description': {'key': 'statusDescription', 'type': 'str'}, - 'conditions': {'key': 'conditions', 'type': '[Condition]'}, - } - - def __init__( - self, - **kwargs - ): - super(CacheHealth, self).__init__(**kwargs) - self.state = kwargs.get('state', None) - self.status_description = kwargs.get('status_description', None) - self.conditions = None - - -class CacheIdentity(msrest.serialization.Model): - """Cache identity properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal ID for the system-assigned identity of the cache. - :vartype principal_id: str - :ivar tenant_id: The tenant ID associated with the cache. - :vartype tenant_id: str - :param type: The type of identity used for the cache. Possible values include: - "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~storage_cache_management_client.models.CacheIdentityType - :param user_assigned_identities: A dictionary where each key is a user assigned identity - resource ID, and each key's value is an empty dictionary. - :type user_assigned_identities: dict[str, - ~storage_cache_management_client.models.UserAssignedIdentitiesValue] - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentitiesValue}'}, - } - - def __init__( - self, - **kwargs - ): - super(CacheIdentity, self).__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = kwargs.get('type', None) - self.user_assigned_identities = kwargs.get('user_assigned_identities', None) - - -class CacheNetworkSettings(msrest.serialization.Model): - """Cache network settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param mtu: The IPv4 maximum transmission unit configured for the subnet. - :type mtu: int - :ivar utility_addresses: Array of additional IP addresses used by this Cache. - :vartype utility_addresses: list[str] - :param dns_servers: DNS servers for the cache to use. It will be set from the network - configuration if no value is provided. - :type dns_servers: list[str] - :param dns_search_domain: DNS search domain. - :type dns_search_domain: str - :param ntp_server: NTP server IP Address or FQDN for the cache to use. The default is - time.windows.com. - :type ntp_server: str - """ - - _validation = { - 'mtu': {'maximum': 1500, 'minimum': 576}, - 'utility_addresses': {'readonly': True}, - } - - _attribute_map = { - 'mtu': {'key': 'mtu', 'type': 'int'}, - 'utility_addresses': {'key': 'utilityAddresses', 'type': '[str]'}, - 'dns_servers': {'key': 'dnsServers', 'type': '[str]'}, - 'dns_search_domain': {'key': 'dnsSearchDomain', 'type': 'str'}, - 'ntp_server': {'key': 'ntpServer', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CacheNetworkSettings, self).__init__(**kwargs) - self.mtu = kwargs.get('mtu', 1500) - self.utility_addresses = None - self.dns_servers = kwargs.get('dns_servers', None) - self.dns_search_domain = kwargs.get('dns_search_domain', None) - self.ntp_server = kwargs.get('ntp_server', "time.windows.com") - - -class CacheSecuritySettings(msrest.serialization.Model): - """Cache security settings. - - :param access_policies: NFS access policies defined for this cache. - :type access_policies: list[~storage_cache_management_client.models.NfsAccessPolicy] - """ - - _attribute_map = { - 'access_policies': {'key': 'accessPolicies', 'type': '[NfsAccessPolicy]'}, - } - - def __init__( - self, - **kwargs - ): - super(CacheSecuritySettings, self).__init__(**kwargs) - self.access_policies = kwargs.get('access_policies', None) - - -class CacheSku(msrest.serialization.Model): - """SKU for the Cache. - - :param name: SKU name for this Cache. - :type name: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CacheSku, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - - -class CachesListResult(msrest.serialization.Model): - """Result of the request to list Caches. It contains a list of Caches and a URL link to get the next set of results. - - :param next_link: URL to get the next set of Cache list results, if there are any. - :type next_link: str - :param value: List of Caches. - :type value: list[~storage_cache_management_client.models.Cache] - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[Cache]'}, - } - - def __init__( - self, - **kwargs - ): - super(CachesListResult, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs.get('value', None) - - -class CacheUpgradeStatus(msrest.serialization.Model): - """Properties describing the software upgrade state of the Cache. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar current_firmware_version: Version string of the firmware currently installed on this - Cache. - :vartype current_firmware_version: str - :ivar firmware_update_status: True if there is a firmware update ready to install on this - Cache. The firmware will automatically be installed after firmwareUpdateDeadline if not - triggered earlier via the upgrade operation. Possible values include: "available", - "unavailable". - :vartype firmware_update_status: str or - ~storage_cache_management_client.models.FirmwareStatusType - :ivar firmware_update_deadline: Time at which the pending firmware update will automatically be - installed on the Cache. - :vartype firmware_update_deadline: ~datetime.datetime - :ivar last_firmware_update: Time of the last successful firmware update. - :vartype last_firmware_update: ~datetime.datetime - :ivar pending_firmware_version: When firmwareUpdateAvailable is true, this field holds the - version string for the update. - :vartype pending_firmware_version: str - """ - - _validation = { - 'current_firmware_version': {'readonly': True}, - 'firmware_update_status': {'readonly': True}, - 'firmware_update_deadline': {'readonly': True}, - 'last_firmware_update': {'readonly': True}, - 'pending_firmware_version': {'readonly': True}, - } - - _attribute_map = { - 'current_firmware_version': {'key': 'currentFirmwareVersion', 'type': 'str'}, - 'firmware_update_status': {'key': 'firmwareUpdateStatus', 'type': 'str'}, - 'firmware_update_deadline': {'key': 'firmwareUpdateDeadline', 'type': 'iso-8601'}, - 'last_firmware_update': {'key': 'lastFirmwareUpdate', 'type': 'iso-8601'}, - 'pending_firmware_version': {'key': 'pendingFirmwareVersion', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CacheUpgradeStatus, self).__init__(**kwargs) - self.current_firmware_version = None - self.firmware_update_status = None - self.firmware_update_deadline = None - self.last_firmware_update = None - self.pending_firmware_version = None - - -class CacheUsernameDownloadSettings(msrest.serialization.Model): - """Settings for Extended Groups username and group download. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param extended_groups: Whether or not Extended Groups is enabled. - :type extended_groups: bool - :param username_source: This setting determines how the cache gets username and group names for - clients. Possible values include: "AD", "LDAP", "File", "None". Default value: "None". - :type username_source: str or ~storage_cache_management_client.models.UsernameSource - :param group_file_uri: The URI of the file containing group information (in /etc/group file - format). This field must be populated when 'usernameSource' is set to 'File'. - :type group_file_uri: str - :param user_file_uri: The URI of the file containing user information (in /etc/passwd file - format). This field must be populated when 'usernameSource' is set to 'File'. - :type user_file_uri: str - :param ldap_server: The fully qualified domain name or IP address of the LDAP server to use. - :type ldap_server: str - :param ldap_base_dn: The base distinguished name for the LDAP domain. - :type ldap_base_dn: str - :param encrypt_ldap_connection: Whether or not the LDAP connection should be encrypted. - :type encrypt_ldap_connection: bool - :param require_valid_certificate: Determines if the certificates must be validated by a - certificate authority. When true, caCertificateURI must be provided. - :type require_valid_certificate: bool - :param auto_download_certificate: Determines if the certificate should be automatically - downloaded. This applies to 'caCertificateURI' only if 'requireValidCertificate' is true. - :type auto_download_certificate: bool - :param ca_certificate_uri: The URI of the CA certificate to validate the LDAP secure - connection. This field must be populated when 'requireValidCertificate' is set to true. - :type ca_certificate_uri: str - :ivar username_downloaded: Indicates whether or not the HPC Cache has performed the username - download successfully. Possible values include: "Yes", "No", "Error". - :vartype username_downloaded: str or - ~storage_cache_management_client.models.UsernameDownloadedType - :param credentials: When present, these are the credentials for the secure LDAP connection. - :type credentials: - ~storage_cache_management_client.models.CacheUsernameDownloadSettingsCredentials - """ - - _validation = { - 'username_downloaded': {'readonly': True}, - } - - _attribute_map = { - 'extended_groups': {'key': 'extendedGroups', 'type': 'bool'}, - 'username_source': {'key': 'usernameSource', 'type': 'str'}, - 'group_file_uri': {'key': 'groupFileURI', 'type': 'str'}, - 'user_file_uri': {'key': 'userFileURI', 'type': 'str'}, - 'ldap_server': {'key': 'ldapServer', 'type': 'str'}, - 'ldap_base_dn': {'key': 'ldapBaseDN', 'type': 'str'}, - 'encrypt_ldap_connection': {'key': 'encryptLdapConnection', 'type': 'bool'}, - 'require_valid_certificate': {'key': 'requireValidCertificate', 'type': 'bool'}, - 'auto_download_certificate': {'key': 'autoDownloadCertificate', 'type': 'bool'}, - 'ca_certificate_uri': {'key': 'caCertificateURI', 'type': 'str'}, - 'username_downloaded': {'key': 'usernameDownloaded', 'type': 'str'}, - 'credentials': {'key': 'credentials', 'type': 'CacheUsernameDownloadSettingsCredentials'}, - } - - def __init__( - self, - **kwargs - ): - super(CacheUsernameDownloadSettings, self).__init__(**kwargs) - self.extended_groups = kwargs.get('extended_groups', None) - self.username_source = kwargs.get('username_source', "None") - self.group_file_uri = kwargs.get('group_file_uri', None) - self.user_file_uri = kwargs.get('user_file_uri', None) - self.ldap_server = kwargs.get('ldap_server', None) - self.ldap_base_dn = kwargs.get('ldap_base_dn', None) - self.encrypt_ldap_connection = kwargs.get('encrypt_ldap_connection', None) - self.require_valid_certificate = kwargs.get('require_valid_certificate', None) - self.auto_download_certificate = kwargs.get('auto_download_certificate', None) - self.ca_certificate_uri = kwargs.get('ca_certificate_uri', None) - self.username_downloaded = None - self.credentials = kwargs.get('credentials', None) - - -class CacheUsernameDownloadSettingsCredentials(msrest.serialization.Model): - """When present, these are the credentials for the secure LDAP connection. - - :param bind_dn: The Bind Distinguished Name identity to be used in the secure LDAP connection. - This value is stored encrypted and not returned on response. - :type bind_dn: str - :param bind_password: The Bind password to be used in the secure LDAP connection. This value is - stored encrypted and not returned on response. - :type bind_password: str - """ - - _attribute_map = { - 'bind_dn': {'key': 'bindDn', 'type': 'str'}, - 'bind_password': {'key': 'bindPassword', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CacheUsernameDownloadSettingsCredentials, self).__init__(**kwargs) - self.bind_dn = kwargs.get('bind_dn', None) - self.bind_password = kwargs.get('bind_password', None) - - -class ClfsTarget(msrest.serialization.Model): - """Properties pertaining to the ClfsTarget. - - :param target: Resource ID of storage container. - :type target: str - """ - - _attribute_map = { - 'target': {'key': 'target', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClfsTarget, self).__init__(**kwargs) - self.target = kwargs.get('target', None) - - -class CloudErrorBody(msrest.serialization.Model): - """An error response. - - :param code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :type code: str - :param details: A list of additional details about the error. - :type details: list[~storage_cache_management_client.models.CloudErrorBody] - :param message: A message describing the error, intended to be suitable for display in a user - interface. - :type message: str - :param target: The target of the particular error. For example, the name of the property in - error. - :type target: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudErrorBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.details = kwargs.get('details', None) - self.message = kwargs.get('message', None) - self.target = kwargs.get('target', None) - - -class Condition(msrest.serialization.Model): - """Outstanding conditions that will need to be resolved. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar timestamp: The time when the condition was raised. - :vartype timestamp: ~datetime.datetime - :ivar message: The issue requiring attention. - :vartype message: str - """ - - _validation = { - 'timestamp': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Condition, self).__init__(**kwargs) - self.timestamp = None - self.message = None - - -class ErrorResponse(msrest.serialization.Model): - """Describes the format of Error response. - - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class KeyVaultKeyReference(msrest.serialization.Model): - """Describes a reference to Key Vault Key. - - All required parameters must be populated in order to send to Azure. - - :param key_url: Required. The URL referencing a key encryption key in Key Vault. - :type key_url: str - :param source_vault: Required. Describes a resource Id to source Key Vault. - :type source_vault: ~storage_cache_management_client.models.KeyVaultKeyReferenceSourceVault - """ - - _validation = { - 'key_url': {'required': True}, - 'source_vault': {'required': True}, - } - - _attribute_map = { - 'key_url': {'key': 'keyUrl', 'type': 'str'}, - 'source_vault': {'key': 'sourceVault', 'type': 'KeyVaultKeyReferenceSourceVault'}, - } - - def __init__( - self, - **kwargs - ): - super(KeyVaultKeyReference, self).__init__(**kwargs) - self.key_url = kwargs['key_url'] - self.source_vault = kwargs['source_vault'] - - -class KeyVaultKeyReferenceSourceVault(msrest.serialization.Model): - """Describes a resource Id to source Key Vault. - - :param id: Resource Id. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(KeyVaultKeyReferenceSourceVault, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - - -class MetricDimension(msrest.serialization.Model): - """Specifications of the Dimension of metrics. - - :param name: Name of the dimension. - :type name: str - :param display_name: Localized friendly display name of the dimension. - :type display_name: str - :param internal_name: Internal name of the dimension. - :type internal_name: str - :param to_be_exported_for_shoebox: To be exported to shoe box. - :type to_be_exported_for_shoebox: bool - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'internal_name': {'key': 'internalName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDimension, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.internal_name = kwargs.get('internal_name', None) - self.to_be_exported_for_shoebox = kwargs.get('to_be_exported_for_shoebox', None) - - -class MetricSpecification(msrest.serialization.Model): - """Details about operation related to metrics. - - :param name: The name of the metric. - :type name: str - :param display_name: Localized display name of the metric. - :type display_name: str - :param display_description: The description of the metric. - :type display_description: str - :param unit: The unit that the metric is measured in. - :type unit: str - :param aggregation_type: The type of metric aggregation. - :type aggregation_type: str - :param supported_aggregation_types: Support metric aggregation type. - :type supported_aggregation_types: list[str or - ~storage_cache_management_client.models.MetricAggregationType] - :param metric_class: Type of metrics. - :type metric_class: str - :param dimensions: Dimensions of the metric. - :type dimensions: list[~storage_cache_management_client.models.MetricDimension] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - 'metric_class': {'key': 'metricClass', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimension]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricSpecification, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.display_description = kwargs.get('display_description', None) - self.unit = kwargs.get('unit', None) - self.aggregation_type = kwargs.get('aggregation_type', None) - self.supported_aggregation_types = kwargs.get('supported_aggregation_types', None) - self.metric_class = kwargs.get('metric_class', None) - self.dimensions = kwargs.get('dimensions', None) - - -class NamespaceJunction(msrest.serialization.Model): - """A namespace junction. - - :param namespace_path: Namespace path on a Cache for a Storage Target. - :type namespace_path: str - :param target_path: Path in Storage Target to which namespacePath points. - :type target_path: str - :param nfs_export: NFS export where targetPath exists. - :type nfs_export: str - :param nfs_access_policy: Name of the access policy applied to this junction. - :type nfs_access_policy: str - """ - - _attribute_map = { - 'namespace_path': {'key': 'namespacePath', 'type': 'str'}, - 'target_path': {'key': 'targetPath', 'type': 'str'}, - 'nfs_export': {'key': 'nfsExport', 'type': 'str'}, - 'nfs_access_policy': {'key': 'nfsAccessPolicy', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NamespaceJunction, self).__init__(**kwargs) - self.namespace_path = kwargs.get('namespace_path', None) - self.target_path = kwargs.get('target_path', None) - self.nfs_export = kwargs.get('nfs_export', None) - self.nfs_access_policy = kwargs.get('nfs_access_policy', "default") - - -class Nfs3Target(msrest.serialization.Model): - """Properties pertaining to the Nfs3Target. - - :param target: IP address or host name of an NFSv3 host (e.g., 10.0.44.44). - :type target: str - :param usage_model: Identifies the StorageCache usage model to be used for this storage target. - :type usage_model: str - """ - - _validation = { - 'target': {'pattern': r'^[-.,0-9a-zA-Z]+$'}, - } - - _attribute_map = { - 'target': {'key': 'target', 'type': 'str'}, - 'usage_model': {'key': 'usageModel', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Nfs3Target, self).__init__(**kwargs) - self.target = kwargs.get('target', None) - self.usage_model = kwargs.get('usage_model', None) - - -class NfsAccessPolicy(msrest.serialization.Model): - """A set of rules describing access policies applied to NFSv3 clients of the cache. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Name identifying this policy. Access Policy names are not case - sensitive. - :type name: str - :param access_rules: Required. The set of rules describing client accesses allowed under this - policy. - :type access_rules: list[~storage_cache_management_client.models.NfsAccessRule] - """ - - _validation = { - 'name': {'required': True}, - 'access_rules': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'access_rules': {'key': 'accessRules', 'type': '[NfsAccessRule]'}, - } - - def __init__( - self, - **kwargs - ): - super(NfsAccessPolicy, self).__init__(**kwargs) - self.name = kwargs['name'] - self.access_rules = kwargs['access_rules'] - - -class NfsAccessRule(msrest.serialization.Model): - """Rule to place restrictions on portions of the cache namespace being presented to clients. - - All required parameters must be populated in order to send to Azure. - - :param scope: Required. Scope for this rule. The scope and filter determine which clients match - the rule. Possible values include: "default", "network", "host". - :type scope: str or ~storage_cache_management_client.models.NfsAccessRuleScope - :param filter: Filter applied to the scope for this rule. The filter's format depends on its - scope. 'default' scope matches all clients and has no filter value. 'network' scope takes a - filter in CIDR format (for example, 10.99.1.0/24). 'host' takes an IP address or fully - qualified domain name as filter. If a client does not match any filter rule and there is no - default rule, access is denied. - :type filter: str - :param access: Required. Access allowed by this rule. Possible values include: "no", "ro", - "rw". - :type access: str or ~storage_cache_management_client.models.NfsAccessRuleAccess - :param suid: Allow SUID semantics. - :type suid: bool - :param submount_access: For the default policy, allow access to subdirectories under the root - export. If this is set to no, clients can only mount the path '/'. If set to yes, clients can - mount a deeper path, like '/a/b'. - :type submount_access: bool - :param root_squash: Map root accesses to anonymousUID and anonymousGID. - :type root_squash: bool - :param anonymous_uid: UID value that replaces 0 when rootSquash is true. 65534 will be used if - not provided. - :type anonymous_uid: str - :param anonymous_gid: GID value that replaces 0 when rootSquash is true. This will use the - value of anonymousUID if not provided. - :type anonymous_gid: str - """ - - _validation = { - 'scope': {'required': True}, - 'access': {'required': True}, - } - - _attribute_map = { - 'scope': {'key': 'scope', 'type': 'str'}, - 'filter': {'key': 'filter', 'type': 'str'}, - 'access': {'key': 'access', 'type': 'str'}, - 'suid': {'key': 'suid', 'type': 'bool'}, - 'submount_access': {'key': 'submountAccess', 'type': 'bool'}, - 'root_squash': {'key': 'rootSquash', 'type': 'bool'}, - 'anonymous_uid': {'key': 'anonymousUID', 'type': 'str'}, - 'anonymous_gid': {'key': 'anonymousGID', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NfsAccessRule, self).__init__(**kwargs) - self.scope = kwargs['scope'] - self.filter = kwargs.get('filter', None) - self.access = kwargs['access'] - self.suid = kwargs.get('suid', None) - self.submount_access = kwargs.get('submount_access', None) - self.root_squash = kwargs.get('root_squash', None) - self.anonymous_uid = kwargs.get('anonymous_uid', None) - self.anonymous_gid = kwargs.get('anonymous_gid', None) - - -class ResourceSku(msrest.serialization.Model): - """A resource SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The type of resource the SKU applies to. - :vartype resource_type: str - :param capabilities: A list of capabilities of this SKU, such as throughput or ops/sec. - :type capabilities: list[~storage_cache_management_client.models.ResourceSkuCapabilities] - :ivar locations: The set of locations where the SKU is available. This is the supported and - registered Azure Geo Regions (e.g., West US, East US, Southeast Asia, etc.). - :vartype locations: list[str] - :param location_info: The set of locations where the SKU is available. - :type location_info: list[~storage_cache_management_client.models.ResourceSkuLocationInfo] - :param name: The name of this SKU. - :type name: str - :param restrictions: The restrictions preventing this SKU from being used. This is empty if - there are no restrictions. - :type restrictions: list[~storage_cache_management_client.models.Restriction] - """ - - _validation = { - 'resource_type': {'readonly': True}, - 'locations': {'readonly': True}, - } - - _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'capabilities': {'key': 'capabilities', 'type': '[ResourceSkuCapabilities]'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[ResourceSkuLocationInfo]'}, - 'name': {'key': 'name', 'type': 'str'}, - 'restrictions': {'key': 'restrictions', 'type': '[Restriction]'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceSku, self).__init__(**kwargs) - self.resource_type = None - self.capabilities = kwargs.get('capabilities', None) - self.locations = None - self.location_info = kwargs.get('location_info', None) - self.name = kwargs.get('name', None) - self.restrictions = kwargs.get('restrictions', None) - - -class ResourceSkuCapabilities(msrest.serialization.Model): - """A resource SKU capability. - - :param name: Name of a capability, such as ops/sec. - :type name: str - :param value: Quantity, if the capability is measured by quantity. - :type value: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceSkuCapabilities, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.value = kwargs.get('value', None) - - -class ResourceSkuLocationInfo(msrest.serialization.Model): - """Resource SKU location information. - - :param location: Location where this SKU is available. - :type location: str - :param zones: Zones if any. - :type zones: list[str] - """ - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceSkuLocationInfo, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.zones = kwargs.get('zones', None) - - -class ResourceSkusResult(msrest.serialization.Model): - """The response from the List Cache SKUs operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param next_link: The URI to fetch the next page of Cache SKUs. - :type next_link: str - :ivar value: The list of SKUs available for the subscription. - :vartype value: list[~storage_cache_management_client.models.ResourceSku] - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[ResourceSku]'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceSkusResult, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = None - - -class Restriction(msrest.serialization.Model): - """The restrictions preventing this SKU from being used. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of restrictions. In this version, the only possible value for this is - location. - :vartype type: str - :ivar values: The value of restrictions. If the restriction type is set to location, then this - would be the different locations where the SKU is restricted. - :vartype values: list[str] - :param reason_code: The reason for the restriction. As of now this can be "QuotaId" or - "NotAvailableForSubscription". "QuotaId" is set when the SKU has requiredQuotas parameter as - the subscription does not belong to that quota. "NotAvailableForSubscription" is related to - capacity at the datacenter. Possible values include: "QuotaId", "NotAvailableForSubscription". - :type reason_code: str or ~storage_cache_management_client.models.ReasonCode - """ - - _validation = { - 'type': {'readonly': True}, - 'values': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Restriction, self).__init__(**kwargs) - self.type = None - self.values = None - self.reason_code = kwargs.get('reason_code', None) - - -class StorageTargetResource(msrest.serialization.Model): - """Resource used by a Cache. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Name of the Storage Target. - :vartype name: str - :ivar id: Resource ID of the Storage Target. - :vartype id: str - :ivar type: Type of the Storage Target; Microsoft.StorageCache/Cache/StorageTarget. - :vartype type: str - :ivar location: Region name string. - :vartype location: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~storage_cache_management_client.models.SystemData - """ - - _validation = { - 'name': {'readonly': True, 'pattern': r'^[-0-9a-zA-Z_]{1,80}$'}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageTargetResource, self).__init__(**kwargs) - self.name = None - self.id = None - self.type = None - self.location = None - self.system_data = None - - -class StorageTarget(StorageTargetResource): - """Type of the Storage Target. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Name of the Storage Target. - :vartype name: str - :ivar id: Resource ID of the Storage Target. - :vartype id: str - :ivar type: Type of the Storage Target; Microsoft.StorageCache/Cache/StorageTarget. - :vartype type: str - :ivar location: Region name string. - :vartype location: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~storage_cache_management_client.models.SystemData - :param junctions: List of Cache namespace junctions to target for namespace associations. - :type junctions: list[~storage_cache_management_client.models.NamespaceJunction] - :param target_type: Type of the Storage Target. Possible values include: "nfs3", "clfs", - "unknown", "blobNfs". - :type target_type: str or ~storage_cache_management_client.models.StorageTargetType - :ivar provisioning_state: ARM provisioning state, see - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. - Possible values include: "Succeeded", "Failed", "Cancelled", "Creating", "Deleting", - "Updating". - :vartype provisioning_state: str or - ~storage_cache_management_client.models.ProvisioningStateType - :param state: Storage target operational state. Possible values include: "Ready", "Busy", - "Suspended", "Flushing". - :type state: str or ~storage_cache_management_client.models.OperationalStateType - :param nfs3: Properties when targetType is nfs3. - :type nfs3: ~storage_cache_management_client.models.Nfs3Target - :param clfs: Properties when targetType is clfs. - :type clfs: ~storage_cache_management_client.models.ClfsTarget - :param unknown: Properties when targetType is unknown. - :type unknown: ~storage_cache_management_client.models.UnknownTarget - :param blob_nfs: Properties when targetType is blobNfs. - :type blob_nfs: ~storage_cache_management_client.models.BlobNfsTarget - """ - - _validation = { - 'name': {'readonly': True, 'pattern': r'^[-0-9a-zA-Z_]{1,80}$'}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'junctions': {'key': 'properties.junctions', 'type': '[NamespaceJunction]'}, - 'target_type': {'key': 'properties.targetType', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'nfs3': {'key': 'properties.nfs3', 'type': 'Nfs3Target'}, - 'clfs': {'key': 'properties.clfs', 'type': 'ClfsTarget'}, - 'unknown': {'key': 'properties.unknown', 'type': 'UnknownTarget'}, - 'blob_nfs': {'key': 'properties.blobNfs', 'type': 'BlobNfsTarget'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageTarget, self).__init__(**kwargs) - self.junctions = kwargs.get('junctions', None) - self.target_type = kwargs.get('target_type', None) - self.provisioning_state = None - self.state = kwargs.get('state', None) - self.nfs3 = kwargs.get('nfs3', None) - self.clfs = kwargs.get('clfs', None) - self.unknown = kwargs.get('unknown', None) - self.blob_nfs = kwargs.get('blob_nfs', None) - - -class StorageTargetsResult(msrest.serialization.Model): - """A list of Storage Targets. - - :param next_link: The URI to fetch the next page of Storage Targets. - :type next_link: str - :param value: The list of Storage Targets defined for the Cache. - :type value: list[~storage_cache_management_client.models.StorageTarget] - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[StorageTarget]'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageTargetsResult, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs.get('value', None) - - -class SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~storage_cache_management_client.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~storage_cache_management_client.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) - - -class UnknownTarget(msrest.serialization.Model): - """Properties pertaining to the UnknownTarget. - - :param attributes: Dictionary of string->string pairs containing information about the Storage - Target. - :type attributes: dict[str, str] - """ - - _attribute_map = { - 'attributes': {'key': 'attributes', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(UnknownTarget, self).__init__(**kwargs) - self.attributes = kwargs.get('attributes', None) - - -class UsageModel(msrest.serialization.Model): - """A usage model. - - :param display: Localized information describing this usage model. - :type display: ~storage_cache_management_client.models.UsageModelDisplay - :param model_name: Non-localized keyword name for this usage model. - :type model_name: str - :param target_type: The type of Storage Target to which this model is applicable (only nfs3 as - of this version). - :type target_type: str - """ - - _attribute_map = { - 'display': {'key': 'display', 'type': 'UsageModelDisplay'}, - 'model_name': {'key': 'modelName', 'type': 'str'}, - 'target_type': {'key': 'targetType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UsageModel, self).__init__(**kwargs) - self.display = kwargs.get('display', None) - self.model_name = kwargs.get('model_name', None) - self.target_type = kwargs.get('target_type', None) - - -class UsageModelDisplay(msrest.serialization.Model): - """Localized information describing this usage model. - - :param description: String to display for this usage model. - :type description: str - """ - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UsageModelDisplay, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - - -class UsageModelsResult(msrest.serialization.Model): - """A list of Cache usage models. - - :param next_link: The URI to fetch the next page of Cache usage models. - :type next_link: str - :param value: The list of usage models available for the subscription. - :type value: list[~storage_cache_management_client.models.UsageModel] - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[UsageModel]'}, - } - - def __init__( - self, - **kwargs - ): - super(UsageModelsResult, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs.get('value', None) - - -class UserAssignedIdentitiesValue(msrest.serialization.Model): - """UserAssignedIdentitiesValue. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal ID of the user-assigned identity. - :vartype principal_id: str - :ivar client_id: The client ID of the user-assigned identity. - :vartype client_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserAssignedIdentitiesValue, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/models/_models_py3.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/models/_models_py3.py index 3ddd000f39e3c..d4933930d112c 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/models/_models_py3.py @@ -17,17 +17,16 @@ class ApiOperation(msrest.serialization.Model): """REST API operation description: see https://github.com/Azure/azure-rest-api-specs/blob/master/documentation/openapi-authoring-automated-guidelines.md#r3023-operationsapiimplementation. - :param display: The object that represents the operation. - :type display: ~storage_cache_management_client.models.ApiOperationDisplay - :param origin: Origin of the operation. - :type origin: str - :param is_data_action: The flag that indicates whether the operation applies to data plane. - :type is_data_action: bool - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param service_specification: Specification of the all the metrics provided for a resource - type. - :type service_specification: + :ivar display: The object that represents the operation. + :vartype display: ~storage_cache_management_client.models.ApiOperationDisplay + :ivar origin: Origin of the operation. + :vartype origin: str + :ivar is_data_action: The flag that indicates whether the operation applies to data plane. + :vartype is_data_action: bool + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar service_specification: Specification of the all the metrics provided for a resource type. + :vartype service_specification: ~storage_cache_management_client.models.ApiOperationPropertiesServiceSpecification """ @@ -49,6 +48,20 @@ def __init__( service_specification: Optional["ApiOperationPropertiesServiceSpecification"] = None, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~storage_cache_management_client.models.ApiOperationDisplay + :keyword origin: Origin of the operation. + :paramtype origin: str + :keyword is_data_action: The flag that indicates whether the operation applies to data plane. + :paramtype is_data_action: bool + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword service_specification: Specification of the all the metrics provided for a resource + type. + :paramtype service_specification: + ~storage_cache_management_client.models.ApiOperationPropertiesServiceSpecification + """ super(ApiOperation, self).__init__(**kwargs) self.display = display self.origin = origin @@ -60,14 +73,14 @@ def __init__( class ApiOperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param provider: Service provider: Microsoft.StorageCache. - :type provider: str - :param resource: Resource on which the operation is performed: Cache, etc. - :type resource: str - :param description: The description of the operation. - :type description: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar provider: Service provider: Microsoft.StorageCache. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Cache, etc. + :vartype resource: str + :ivar description: The description of the operation. + :vartype description: str """ _attribute_map = { @@ -86,6 +99,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword provider: Service provider: Microsoft.StorageCache. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Cache, etc. + :paramtype resource: str + :keyword description: The description of the operation. + :paramtype description: str + """ super(ApiOperationDisplay, self).__init__(**kwargs) self.operation = operation self.provider = provider @@ -96,11 +119,11 @@ def __init__( class ApiOperationListResult(msrest.serialization.Model): """Result of the request to list Resource Provider operations. It contains a list of operations and a URL link to get the next set of results. - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str - :param value: List of Resource Provider operations supported by the Microsoft.StorageCache + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str + :ivar value: List of Resource Provider operations supported by the Microsoft.StorageCache resource provider. - :type value: list[~storage_cache_management_client.models.ApiOperation] + :vartype value: list[~storage_cache_management_client.models.ApiOperation] """ _attribute_map = { @@ -115,6 +138,13 @@ def __init__( value: Optional[List["ApiOperation"]] = None, **kwargs ): + """ + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + :keyword value: List of Resource Provider operations supported by the Microsoft.StorageCache + resource provider. + :paramtype value: list[~storage_cache_management_client.models.ApiOperation] + """ super(ApiOperationListResult, self).__init__(**kwargs) self.next_link = next_link self.value = value @@ -123,8 +153,9 @@ def __init__( class ApiOperationPropertiesServiceSpecification(msrest.serialization.Model): """Specification of the all the metrics provided for a resource type. - :param metric_specifications: Details about operations related to metrics. - :type metric_specifications: list[~storage_cache_management_client.models.MetricSpecification] + :ivar metric_specifications: Details about operations related to metrics. + :vartype metric_specifications: + list[~storage_cache_management_client.models.MetricSpecification] """ _attribute_map = { @@ -137,6 +168,11 @@ def __init__( metric_specifications: Optional[List["MetricSpecification"]] = None, **kwargs ): + """ + :keyword metric_specifications: Details about operations related to metrics. + :paramtype metric_specifications: + list[~storage_cache_management_client.models.MetricSpecification] + """ super(ApiOperationPropertiesServiceSpecification, self).__init__(**kwargs) self.metric_specifications = metric_specifications @@ -144,20 +180,20 @@ def __init__( class AscOperation(msrest.serialization.Model): """The status of operation. - :param id: The operation Id. - :type id: str - :param name: The operation name. - :type name: str - :param start_time: The start time of the operation. - :type start_time: str - :param end_time: The end time of the operation. - :type end_time: str - :param status: The status of the operation. - :type status: str - :param error: The error detail of the operation if any. - :type error: ~storage_cache_management_client.models.ErrorResponse - :param output: Additional operation-specific output. - :type output: dict[str, any] + :ivar id: The operation Id. + :vartype id: str + :ivar name: The operation name. + :vartype name: str + :ivar start_time: The start time of the operation. + :vartype start_time: str + :ivar end_time: The end time of the operation. + :vartype end_time: str + :ivar status: The status of the operation. + :vartype status: str + :ivar error: The error detail of the operation if any. + :vartype error: ~storage_cache_management_client.models.ErrorResponse + :ivar output: Additional operation-specific output. + :vartype output: dict[str, any] """ _attribute_map = { @@ -182,6 +218,22 @@ def __init__( output: Optional[Dict[str, Any]] = None, **kwargs ): + """ + :keyword id: The operation Id. + :paramtype id: str + :keyword name: The operation name. + :paramtype name: str + :keyword start_time: The start time of the operation. + :paramtype start_time: str + :keyword end_time: The end time of the operation. + :paramtype end_time: str + :keyword status: The status of the operation. + :paramtype status: str + :keyword error: The error detail of the operation if any. + :paramtype error: ~storage_cache_management_client.models.ErrorResponse + :keyword output: Additional operation-specific output. + :paramtype output: dict[str, any] + """ super(AscOperation, self).__init__(**kwargs) self.id = id self.name = name @@ -195,10 +247,10 @@ def __init__( class BlobNfsTarget(msrest.serialization.Model): """Properties pertaining to the BlobNfsTarget. - :param target: Resource ID of the storage container. - :type target: str - :param usage_model: Identifies the StorageCache usage model to be used for this storage target. - :type usage_model: str + :ivar target: Resource ID of the storage container. + :vartype target: str + :ivar usage_model: Identifies the StorageCache usage model to be used for this storage target. + :vartype usage_model: str """ _attribute_map = { @@ -213,6 +265,13 @@ def __init__( usage_model: Optional[str] = None, **kwargs ): + """ + :keyword target: Resource ID of the storage container. + :paramtype target: str + :keyword usage_model: Identifies the StorageCache usage model to be used for this storage + target. + :paramtype usage_model: str + """ super(BlobNfsTarget, self).__init__(**kwargs) self.target = target self.usage_model = usage_model @@ -223,24 +282,24 @@ class Cache(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] :ivar id: Resource ID of the Cache. :vartype id: str - :param location: Region name string. - :type location: str + :ivar location: Region name string. + :vartype location: str :ivar name: Name of Cache. :vartype name: str :ivar type: Type of the Cache; Microsoft.StorageCache/Cache. :vartype type: str - :param identity: The identity of the cache, if configured. - :type identity: ~storage_cache_management_client.models.CacheIdentity + :ivar identity: The identity of the cache, if configured. + :vartype identity: ~storage_cache_management_client.models.CacheIdentity :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~storage_cache_management_client.models.SystemData - :param sku: SKU for the Cache. - :type sku: ~storage_cache_management_client.models.CacheSku - :param cache_size_gb: The size of this Cache, in GB. - :type cache_size_gb: int + :ivar sku: SKU for the Cache. + :vartype sku: ~storage_cache_management_client.models.CacheSku + :ivar cache_size_gb: The size of this Cache, in GB. + :vartype cache_size_gb: int :ivar health: Health of the Cache. :vartype health: ~storage_cache_management_client.models.CacheHealth :ivar mount_addresses: Array of IP addresses that can be used by clients mounting this Cache. @@ -251,19 +310,22 @@ class Cache(msrest.serialization.Model): "Updating". :vartype provisioning_state: str or ~storage_cache_management_client.models.ProvisioningStateType - :param subnet: Subnet used for the Cache. - :type subnet: str + :ivar subnet: Subnet used for the Cache. + :vartype subnet: str :ivar upgrade_status: Upgrade status of the Cache. :vartype upgrade_status: ~storage_cache_management_client.models.CacheUpgradeStatus - :param network_settings: Specifies network settings of the cache. - :type network_settings: ~storage_cache_management_client.models.CacheNetworkSettings - :param encryption_settings: Specifies encryption settings of the cache. - :type encryption_settings: ~storage_cache_management_client.models.CacheEncryptionSettings - :param security_settings: Specifies security settings of the cache. - :type security_settings: ~storage_cache_management_client.models.CacheSecuritySettings - :param directory_services_settings: Specifies Directory Services settings of the cache. - :type directory_services_settings: + :ivar network_settings: Specifies network settings of the cache. + :vartype network_settings: ~storage_cache_management_client.models.CacheNetworkSettings + :ivar encryption_settings: Specifies encryption settings of the cache. + :vartype encryption_settings: ~storage_cache_management_client.models.CacheEncryptionSettings + :ivar security_settings: Specifies security settings of the cache. + :vartype security_settings: ~storage_cache_management_client.models.CacheSecuritySettings + :ivar directory_services_settings: Specifies Directory Services settings of the cache. + :vartype directory_services_settings: ~storage_cache_management_client.models.CacheDirectorySettings + :ivar zones: Availability zones for resources. This field should only contain a single element + in the array. + :vartype zones: list[str] """ _validation = { @@ -296,6 +358,7 @@ class Cache(msrest.serialization.Model): 'encryption_settings': {'key': 'properties.encryptionSettings', 'type': 'CacheEncryptionSettings'}, 'security_settings': {'key': 'properties.securitySettings', 'type': 'CacheSecuritySettings'}, 'directory_services_settings': {'key': 'properties.directoryServicesSettings', 'type': 'CacheDirectorySettings'}, + 'zones': {'key': 'properties.zones', 'type': '[str]'}, } def __init__( @@ -311,8 +374,35 @@ def __init__( encryption_settings: Optional["CacheEncryptionSettings"] = None, security_settings: Optional["CacheSecuritySettings"] = None, directory_services_settings: Optional["CacheDirectorySettings"] = None, + zones: Optional[List[str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Region name string. + :paramtype location: str + :keyword identity: The identity of the cache, if configured. + :paramtype identity: ~storage_cache_management_client.models.CacheIdentity + :keyword sku: SKU for the Cache. + :paramtype sku: ~storage_cache_management_client.models.CacheSku + :keyword cache_size_gb: The size of this Cache, in GB. + :paramtype cache_size_gb: int + :keyword subnet: Subnet used for the Cache. + :paramtype subnet: str + :keyword network_settings: Specifies network settings of the cache. + :paramtype network_settings: ~storage_cache_management_client.models.CacheNetworkSettings + :keyword encryption_settings: Specifies encryption settings of the cache. + :paramtype encryption_settings: ~storage_cache_management_client.models.CacheEncryptionSettings + :keyword security_settings: Specifies security settings of the cache. + :paramtype security_settings: ~storage_cache_management_client.models.CacheSecuritySettings + :keyword directory_services_settings: Specifies Directory Services settings of the cache. + :paramtype directory_services_settings: + ~storage_cache_management_client.models.CacheDirectorySettings + :keyword zones: Availability zones for resources. This field should only contain a single + element in the array. + :paramtype zones: list[str] + """ super(Cache, self).__init__(**kwargs) self.tags = tags self.id = None @@ -332,6 +422,7 @@ def __init__( self.encryption_settings = encryption_settings self.security_settings = security_settings self.directory_services_settings = directory_services_settings + self.zones = zones class CacheActiveDirectorySettings(msrest.serialization.Model): @@ -341,26 +432,26 @@ class CacheActiveDirectorySettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param primary_dns_ip_address: Required. Primary DNS IP address used to resolve the Active + :ivar primary_dns_ip_address: Required. Primary DNS IP address used to resolve the Active Directory domain controller's fully qualified domain name. - :type primary_dns_ip_address: str - :param secondary_dns_ip_address: Secondary DNS IP address used to resolve the Active Directory + :vartype primary_dns_ip_address: str + :ivar secondary_dns_ip_address: Secondary DNS IP address used to resolve the Active Directory domain controller's fully qualified domain name. - :type secondary_dns_ip_address: str - :param domain_name: Required. The fully qualified domain name of the Active Directory domain + :vartype secondary_dns_ip_address: str + :ivar domain_name: Required. The fully qualified domain name of the Active Directory domain controller. - :type domain_name: str - :param domain_net_bios_name: Required. The Active Directory domain's NetBIOS name. - :type domain_net_bios_name: str - :param cache_net_bios_name: Required. The NetBIOS name to assign to the HPC Cache when it joins + :vartype domain_name: str + :ivar domain_net_bios_name: Required. The Active Directory domain's NetBIOS name. + :vartype domain_net_bios_name: str + :ivar cache_net_bios_name: Required. The NetBIOS name to assign to the HPC Cache when it joins the Active Directory domain as a server. Length must 1-15 characters from the class [-0-9a-zA-Z]. - :type cache_net_bios_name: str + :vartype cache_net_bios_name: str :ivar domain_joined: True if the HPC Cache is joined to the Active Directory domain. Possible values include: "Yes", "No", "Error". :vartype domain_joined: str or ~storage_cache_management_client.models.DomainJoinedType - :param credentials: Active Directory admin credentials used to join the HPC Cache to a domain. - :type credentials: + :ivar credentials: Active Directory admin credentials used to join the HPC Cache to a domain. + :vartype credentials: ~storage_cache_management_client.models.CacheActiveDirectorySettingsCredentials """ @@ -393,6 +484,27 @@ def __init__( credentials: Optional["CacheActiveDirectorySettingsCredentials"] = None, **kwargs ): + """ + :keyword primary_dns_ip_address: Required. Primary DNS IP address used to resolve the Active + Directory domain controller's fully qualified domain name. + :paramtype primary_dns_ip_address: str + :keyword secondary_dns_ip_address: Secondary DNS IP address used to resolve the Active + Directory domain controller's fully qualified domain name. + :paramtype secondary_dns_ip_address: str + :keyword domain_name: Required. The fully qualified domain name of the Active Directory domain + controller. + :paramtype domain_name: str + :keyword domain_net_bios_name: Required. The Active Directory domain's NetBIOS name. + :paramtype domain_net_bios_name: str + :keyword cache_net_bios_name: Required. The NetBIOS name to assign to the HPC Cache when it + joins the Active Directory domain as a server. Length must 1-15 characters from the class + [-0-9a-zA-Z]. + :paramtype cache_net_bios_name: str + :keyword credentials: Active Directory admin credentials used to join the HPC Cache to a + domain. + :paramtype credentials: + ~storage_cache_management_client.models.CacheActiveDirectorySettingsCredentials + """ super(CacheActiveDirectorySettings, self).__init__(**kwargs) self.primary_dns_ip_address = primary_dns_ip_address self.secondary_dns_ip_address = secondary_dns_ip_address @@ -408,12 +520,12 @@ class CacheActiveDirectorySettingsCredentials(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param username: Required. Username of the Active Directory domain administrator. This value is + :ivar username: Required. Username of the Active Directory domain administrator. This value is stored encrypted and not returned on response. - :type username: str - :param password: Required. Plain text password of the Active Directory domain administrator. + :vartype username: str + :ivar password: Required. Plain text password of the Active Directory domain administrator. This value is stored encrypted and not returned on response. - :type password: str + :vartype password: str """ _validation = { @@ -433,6 +545,14 @@ def __init__( password: str, **kwargs ): + """ + :keyword username: Required. Username of the Active Directory domain administrator. This value + is stored encrypted and not returned on response. + :paramtype username: str + :keyword password: Required. Plain text password of the Active Directory domain administrator. + This value is stored encrypted and not returned on response. + :paramtype password: str + """ super(CacheActiveDirectorySettingsCredentials, self).__init__(**kwargs) self.username = username self.password = password @@ -441,12 +561,13 @@ def __init__( class CacheDirectorySettings(msrest.serialization.Model): """Cache Directory Services settings. - :param active_directory: Specifies settings for joining the HPC Cache to an Active Directory + :ivar active_directory: Specifies settings for joining the HPC Cache to an Active Directory domain. - :type active_directory: ~storage_cache_management_client.models.CacheActiveDirectorySettings - :param username_download: Specifies settings for Extended Groups. Extended Groups allows users + :vartype active_directory: ~storage_cache_management_client.models.CacheActiveDirectorySettings + :ivar username_download: Specifies settings for Extended Groups. Extended Groups allows users to be members of more than 16 groups. - :type username_download: ~storage_cache_management_client.models.CacheUsernameDownloadSettings + :vartype username_download: + ~storage_cache_management_client.models.CacheUsernameDownloadSettings """ _attribute_map = { @@ -461,6 +582,16 @@ def __init__( username_download: Optional["CacheUsernameDownloadSettings"] = None, **kwargs ): + """ + :keyword active_directory: Specifies settings for joining the HPC Cache to an Active Directory + domain. + :paramtype active_directory: + ~storage_cache_management_client.models.CacheActiveDirectorySettings + :keyword username_download: Specifies settings for Extended Groups. Extended Groups allows + users to be members of more than 16 groups. + :paramtype username_download: + ~storage_cache_management_client.models.CacheUsernameDownloadSettings + """ super(CacheDirectorySettings, self).__init__(**kwargs) self.active_directory = active_directory self.username_download = username_download @@ -469,11 +600,11 @@ def __init__( class CacheEncryptionSettings(msrest.serialization.Model): """Cache encryption settings. - :param key_encryption_key: Specifies the location of the key encryption key in Key Vault. - :type key_encryption_key: ~storage_cache_management_client.models.KeyVaultKeyReference - :param rotation_to_latest_key_version_enabled: Specifies whether the service will automatically + :ivar key_encryption_key: Specifies the location of the key encryption key in Key Vault. + :vartype key_encryption_key: ~storage_cache_management_client.models.KeyVaultKeyReference + :ivar rotation_to_latest_key_version_enabled: Specifies whether the service will automatically rotate to the newest version of the key in the Key Vault. - :type rotation_to_latest_key_version_enabled: bool + :vartype rotation_to_latest_key_version_enabled: bool """ _attribute_map = { @@ -488,6 +619,13 @@ def __init__( rotation_to_latest_key_version_enabled: Optional[bool] = None, **kwargs ): + """ + :keyword key_encryption_key: Specifies the location of the key encryption key in Key Vault. + :paramtype key_encryption_key: ~storage_cache_management_client.models.KeyVaultKeyReference + :keyword rotation_to_latest_key_version_enabled: Specifies whether the service will + automatically rotate to the newest version of the key in the Key Vault. + :paramtype rotation_to_latest_key_version_enabled: bool + """ super(CacheEncryptionSettings, self).__init__(**kwargs) self.key_encryption_key = key_encryption_key self.rotation_to_latest_key_version_enabled = rotation_to_latest_key_version_enabled @@ -498,11 +636,11 @@ class CacheHealth(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param state: List of Cache health states. Possible values include: "Unknown", "Healthy", + :ivar state: List of Cache health states. Possible values include: "Unknown", "Healthy", "Degraded", "Down", "Transitioning", "Stopping", "Stopped", "Upgrading", "Flushing". - :type state: str or ~storage_cache_management_client.models.HealthStateType - :param status_description: Describes explanation of state. - :type status_description: str + :vartype state: str or ~storage_cache_management_client.models.HealthStateType + :ivar status_description: Describes explanation of state. + :vartype status_description: str :ivar conditions: Outstanding conditions that need to be investigated and resolved. :vartype conditions: list[~storage_cache_management_client.models.Condition] """ @@ -524,6 +662,13 @@ def __init__( status_description: Optional[str] = None, **kwargs ): + """ + :keyword state: List of Cache health states. Possible values include: "Unknown", "Healthy", + "Degraded", "Down", "Transitioning", "Stopping", "Stopped", "Upgrading", "Flushing". + :paramtype state: str or ~storage_cache_management_client.models.HealthStateType + :keyword status_description: Describes explanation of state. + :paramtype status_description: str + """ super(CacheHealth, self).__init__(**kwargs) self.state = state self.status_description = status_description @@ -539,12 +684,12 @@ class CacheIdentity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID associated with the cache. :vartype tenant_id: str - :param type: The type of identity used for the cache. Possible values include: - "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~storage_cache_management_client.models.CacheIdentityType - :param user_assigned_identities: A dictionary where each key is a user assigned identity + :ivar type: The type of identity used for the cache. Possible values include: "SystemAssigned", + "UserAssigned", "SystemAssigned, UserAssigned", "None". + :vartype type: str or ~storage_cache_management_client.models.CacheIdentityType + :ivar user_assigned_identities: A dictionary where each key is a user assigned identity resource ID, and each key's value is an empty dictionary. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~storage_cache_management_client.models.UserAssignedIdentitiesValue] """ @@ -567,6 +712,15 @@ def __init__( user_assigned_identities: Optional[Dict[str, "UserAssignedIdentitiesValue"]] = None, **kwargs ): + """ + :keyword type: The type of identity used for the cache. Possible values include: + "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~storage_cache_management_client.models.CacheIdentityType + :keyword user_assigned_identities: A dictionary where each key is a user assigned identity + resource ID, and each key's value is an empty dictionary. + :paramtype user_assigned_identities: dict[str, + ~storage_cache_management_client.models.UserAssignedIdentitiesValue] + """ super(CacheIdentity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -579,18 +733,18 @@ class CacheNetworkSettings(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param mtu: The IPv4 maximum transmission unit configured for the subnet. - :type mtu: int + :ivar mtu: The IPv4 maximum transmission unit configured for the subnet. + :vartype mtu: int :ivar utility_addresses: Array of additional IP addresses used by this Cache. :vartype utility_addresses: list[str] - :param dns_servers: DNS servers for the cache to use. It will be set from the network + :ivar dns_servers: DNS servers for the cache to use. It will be set from the network configuration if no value is provided. - :type dns_servers: list[str] - :param dns_search_domain: DNS search domain. - :type dns_search_domain: str - :param ntp_server: NTP server IP Address or FQDN for the cache to use. The default is + :vartype dns_servers: list[str] + :ivar dns_search_domain: DNS search domain. + :vartype dns_search_domain: str + :ivar ntp_server: NTP server IP Address or FQDN for the cache to use. The default is time.windows.com. - :type ntp_server: str + :vartype ntp_server: str """ _validation = { @@ -615,6 +769,18 @@ def __init__( ntp_server: Optional[str] = "time.windows.com", **kwargs ): + """ + :keyword mtu: The IPv4 maximum transmission unit configured for the subnet. + :paramtype mtu: int + :keyword dns_servers: DNS servers for the cache to use. It will be set from the network + configuration if no value is provided. + :paramtype dns_servers: list[str] + :keyword dns_search_domain: DNS search domain. + :paramtype dns_search_domain: str + :keyword ntp_server: NTP server IP Address or FQDN for the cache to use. The default is + time.windows.com. + :paramtype ntp_server: str + """ super(CacheNetworkSettings, self).__init__(**kwargs) self.mtu = mtu self.utility_addresses = None @@ -626,8 +792,8 @@ def __init__( class CacheSecuritySettings(msrest.serialization.Model): """Cache security settings. - :param access_policies: NFS access policies defined for this cache. - :type access_policies: list[~storage_cache_management_client.models.NfsAccessPolicy] + :ivar access_policies: NFS access policies defined for this cache. + :vartype access_policies: list[~storage_cache_management_client.models.NfsAccessPolicy] """ _attribute_map = { @@ -640,6 +806,10 @@ def __init__( access_policies: Optional[List["NfsAccessPolicy"]] = None, **kwargs ): + """ + :keyword access_policies: NFS access policies defined for this cache. + :paramtype access_policies: list[~storage_cache_management_client.models.NfsAccessPolicy] + """ super(CacheSecuritySettings, self).__init__(**kwargs) self.access_policies = access_policies @@ -647,8 +817,8 @@ def __init__( class CacheSku(msrest.serialization.Model): """SKU for the Cache. - :param name: SKU name for this Cache. - :type name: str + :ivar name: SKU name for this Cache. + :vartype name: str """ _attribute_map = { @@ -661,6 +831,10 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword name: SKU name for this Cache. + :paramtype name: str + """ super(CacheSku, self).__init__(**kwargs) self.name = name @@ -668,10 +842,10 @@ def __init__( class CachesListResult(msrest.serialization.Model): """Result of the request to list Caches. It contains a list of Caches and a URL link to get the next set of results. - :param next_link: URL to get the next set of Cache list results, if there are any. - :type next_link: str - :param value: List of Caches. - :type value: list[~storage_cache_management_client.models.Cache] + :ivar next_link: URL to get the next set of Cache list results, if there are any. + :vartype next_link: str + :ivar value: List of Caches. + :vartype value: list[~storage_cache_management_client.models.Cache] """ _attribute_map = { @@ -686,6 +860,12 @@ def __init__( value: Optional[List["Cache"]] = None, **kwargs ): + """ + :keyword next_link: URL to get the next set of Cache list results, if there are any. + :paramtype next_link: str + :keyword value: List of Caches. + :paramtype value: list[~storage_cache_management_client.models.Cache] + """ super(CachesListResult, self).__init__(**kwargs) self.next_link = next_link self.value = value @@ -735,6 +915,8 @@ def __init__( self, **kwargs ): + """ + """ super(CacheUpgradeStatus, self).__init__(**kwargs) self.current_firmware_version = None self.firmware_update_status = None @@ -748,38 +930,38 @@ class CacheUsernameDownloadSettings(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param extended_groups: Whether or not Extended Groups is enabled. - :type extended_groups: bool - :param username_source: This setting determines how the cache gets username and group names for + :ivar extended_groups: Whether or not Extended Groups is enabled. + :vartype extended_groups: bool + :ivar username_source: This setting determines how the cache gets username and group names for clients. Possible values include: "AD", "LDAP", "File", "None". Default value: "None". - :type username_source: str or ~storage_cache_management_client.models.UsernameSource - :param group_file_uri: The URI of the file containing group information (in /etc/group file + :vartype username_source: str or ~storage_cache_management_client.models.UsernameSource + :ivar group_file_uri: The URI of the file containing group information (in /etc/group file format). This field must be populated when 'usernameSource' is set to 'File'. - :type group_file_uri: str - :param user_file_uri: The URI of the file containing user information (in /etc/passwd file + :vartype group_file_uri: str + :ivar user_file_uri: The URI of the file containing user information (in /etc/passwd file format). This field must be populated when 'usernameSource' is set to 'File'. - :type user_file_uri: str - :param ldap_server: The fully qualified domain name or IP address of the LDAP server to use. - :type ldap_server: str - :param ldap_base_dn: The base distinguished name for the LDAP domain. - :type ldap_base_dn: str - :param encrypt_ldap_connection: Whether or not the LDAP connection should be encrypted. - :type encrypt_ldap_connection: bool - :param require_valid_certificate: Determines if the certificates must be validated by a + :vartype user_file_uri: str + :ivar ldap_server: The fully qualified domain name or IP address of the LDAP server to use. + :vartype ldap_server: str + :ivar ldap_base_dn: The base distinguished name for the LDAP domain. + :vartype ldap_base_dn: str + :ivar encrypt_ldap_connection: Whether or not the LDAP connection should be encrypted. + :vartype encrypt_ldap_connection: bool + :ivar require_valid_certificate: Determines if the certificates must be validated by a certificate authority. When true, caCertificateURI must be provided. - :type require_valid_certificate: bool - :param auto_download_certificate: Determines if the certificate should be automatically + :vartype require_valid_certificate: bool + :ivar auto_download_certificate: Determines if the certificate should be automatically downloaded. This applies to 'caCertificateURI' only if 'requireValidCertificate' is true. - :type auto_download_certificate: bool - :param ca_certificate_uri: The URI of the CA certificate to validate the LDAP secure - connection. This field must be populated when 'requireValidCertificate' is set to true. - :type ca_certificate_uri: str + :vartype auto_download_certificate: bool + :ivar ca_certificate_uri: The URI of the CA certificate to validate the LDAP secure connection. + This field must be populated when 'requireValidCertificate' is set to true. + :vartype ca_certificate_uri: str :ivar username_downloaded: Indicates whether or not the HPC Cache has performed the username download successfully. Possible values include: "Yes", "No", "Error". :vartype username_downloaded: str or ~storage_cache_management_client.models.UsernameDownloadedType - :param credentials: When present, these are the credentials for the secure LDAP connection. - :type credentials: + :ivar credentials: When present, these are the credentials for the secure LDAP connection. + :vartype credentials: ~storage_cache_management_client.models.CacheUsernameDownloadSettingsCredentials """ @@ -818,6 +1000,37 @@ def __init__( credentials: Optional["CacheUsernameDownloadSettingsCredentials"] = None, **kwargs ): + """ + :keyword extended_groups: Whether or not Extended Groups is enabled. + :paramtype extended_groups: bool + :keyword username_source: This setting determines how the cache gets username and group names + for clients. Possible values include: "AD", "LDAP", "File", "None". Default value: "None". + :paramtype username_source: str or ~storage_cache_management_client.models.UsernameSource + :keyword group_file_uri: The URI of the file containing group information (in /etc/group file + format). This field must be populated when 'usernameSource' is set to 'File'. + :paramtype group_file_uri: str + :keyword user_file_uri: The URI of the file containing user information (in /etc/passwd file + format). This field must be populated when 'usernameSource' is set to 'File'. + :paramtype user_file_uri: str + :keyword ldap_server: The fully qualified domain name or IP address of the LDAP server to use. + :paramtype ldap_server: str + :keyword ldap_base_dn: The base distinguished name for the LDAP domain. + :paramtype ldap_base_dn: str + :keyword encrypt_ldap_connection: Whether or not the LDAP connection should be encrypted. + :paramtype encrypt_ldap_connection: bool + :keyword require_valid_certificate: Determines if the certificates must be validated by a + certificate authority. When true, caCertificateURI must be provided. + :paramtype require_valid_certificate: bool + :keyword auto_download_certificate: Determines if the certificate should be automatically + downloaded. This applies to 'caCertificateURI' only if 'requireValidCertificate' is true. + :paramtype auto_download_certificate: bool + :keyword ca_certificate_uri: The URI of the CA certificate to validate the LDAP secure + connection. This field must be populated when 'requireValidCertificate' is set to true. + :paramtype ca_certificate_uri: str + :keyword credentials: When present, these are the credentials for the secure LDAP connection. + :paramtype credentials: + ~storage_cache_management_client.models.CacheUsernameDownloadSettingsCredentials + """ super(CacheUsernameDownloadSettings, self).__init__(**kwargs) self.extended_groups = extended_groups self.username_source = username_source @@ -836,12 +1049,12 @@ def __init__( class CacheUsernameDownloadSettingsCredentials(msrest.serialization.Model): """When present, these are the credentials for the secure LDAP connection. - :param bind_dn: The Bind Distinguished Name identity to be used in the secure LDAP connection. + :ivar bind_dn: The Bind Distinguished Name identity to be used in the secure LDAP connection. This value is stored encrypted and not returned on response. - :type bind_dn: str - :param bind_password: The Bind password to be used in the secure LDAP connection. This value is + :vartype bind_dn: str + :ivar bind_password: The Bind password to be used in the secure LDAP connection. This value is stored encrypted and not returned on response. - :type bind_password: str + :vartype bind_password: str """ _attribute_map = { @@ -856,6 +1069,14 @@ def __init__( bind_password: Optional[str] = None, **kwargs ): + """ + :keyword bind_dn: The Bind Distinguished Name identity to be used in the secure LDAP + connection. This value is stored encrypted and not returned on response. + :paramtype bind_dn: str + :keyword bind_password: The Bind password to be used in the secure LDAP connection. This value + is stored encrypted and not returned on response. + :paramtype bind_password: str + """ super(CacheUsernameDownloadSettingsCredentials, self).__init__(**kwargs) self.bind_dn = bind_dn self.bind_password = bind_password @@ -864,8 +1085,8 @@ def __init__( class ClfsTarget(msrest.serialization.Model): """Properties pertaining to the ClfsTarget. - :param target: Resource ID of storage container. - :type target: str + :ivar target: Resource ID of storage container. + :vartype target: str """ _attribute_map = { @@ -878,6 +1099,10 @@ def __init__( target: Optional[str] = None, **kwargs ): + """ + :keyword target: Resource ID of storage container. + :paramtype target: str + """ super(ClfsTarget, self).__init__(**kwargs) self.target = target @@ -885,17 +1110,17 @@ def __init__( class CloudErrorBody(msrest.serialization.Model): """An error response. - :param code: An identifier for the error. Codes are invariant and are intended to be consumed + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - :type code: str - :param details: A list of additional details about the error. - :type details: list[~storage_cache_management_client.models.CloudErrorBody] - :param message: A message describing the error, intended to be suitable for display in a user + :vartype code: str + :ivar details: A list of additional details about the error. + :vartype details: list[~storage_cache_management_client.models.CloudErrorBody] + :ivar message: A message describing the error, intended to be suitable for display in a user interface. - :type message: str - :param target: The target of the particular error. For example, the name of the property in + :vartype message: str + :ivar target: The target of the particular error. For example, the name of the property in error. - :type target: str + :vartype target: str """ _attribute_map = { @@ -914,6 +1139,19 @@ def __init__( target: Optional[str] = None, **kwargs ): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~storage_cache_management_client.models.CloudErrorBody] + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword target: The target of the particular error. For example, the name of the property in + error. + :paramtype target: str + """ super(CloudErrorBody, self).__init__(**kwargs) self.code = code self.details = details @@ -946,6 +1184,8 @@ def __init__( self, **kwargs ): + """ + """ super(Condition, self).__init__(**kwargs) self.timestamp = None self.message = None @@ -954,10 +1194,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -972,6 +1212,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -982,10 +1228,10 @@ class KeyVaultKeyReference(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key_url: Required. The URL referencing a key encryption key in Key Vault. - :type key_url: str - :param source_vault: Required. Describes a resource Id to source Key Vault. - :type source_vault: ~storage_cache_management_client.models.KeyVaultKeyReferenceSourceVault + :ivar key_url: Required. The URL referencing a key encryption key in Key Vault. + :vartype key_url: str + :ivar source_vault: Required. Describes a resource Id to source Key Vault. + :vartype source_vault: ~storage_cache_management_client.models.KeyVaultKeyReferenceSourceVault """ _validation = { @@ -1005,6 +1251,13 @@ def __init__( source_vault: "KeyVaultKeyReferenceSourceVault", **kwargs ): + """ + :keyword key_url: Required. The URL referencing a key encryption key in Key Vault. + :paramtype key_url: str + :keyword source_vault: Required. Describes a resource Id to source Key Vault. + :paramtype source_vault: + ~storage_cache_management_client.models.KeyVaultKeyReferenceSourceVault + """ super(KeyVaultKeyReference, self).__init__(**kwargs) self.key_url = key_url self.source_vault = source_vault @@ -1013,8 +1266,8 @@ def __init__( class KeyVaultKeyReferenceSourceVault(msrest.serialization.Model): """Describes a resource Id to source Key Vault. - :param id: Resource Id. - :type id: str + :ivar id: Resource Id. + :vartype id: str """ _attribute_map = { @@ -1027,6 +1280,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource Id. + :paramtype id: str + """ super(KeyVaultKeyReferenceSourceVault, self).__init__(**kwargs) self.id = id @@ -1034,14 +1291,14 @@ def __init__( class MetricDimension(msrest.serialization.Model): """Specifications of the Dimension of metrics. - :param name: Name of the dimension. - :type name: str - :param display_name: Localized friendly display name of the dimension. - :type display_name: str - :param internal_name: Internal name of the dimension. - :type internal_name: str - :param to_be_exported_for_shoebox: To be exported to shoe box. - :type to_be_exported_for_shoebox: bool + :ivar name: Name of the dimension. + :vartype name: str + :ivar display_name: Localized friendly display name of the dimension. + :vartype display_name: str + :ivar internal_name: Internal name of the dimension. + :vartype internal_name: str + :ivar to_be_exported_for_shoebox: To be exported to shoe box. + :vartype to_be_exported_for_shoebox: bool """ _attribute_map = { @@ -1060,6 +1317,16 @@ def __init__( to_be_exported_for_shoebox: Optional[bool] = None, **kwargs ): + """ + :keyword name: Name of the dimension. + :paramtype name: str + :keyword display_name: Localized friendly display name of the dimension. + :paramtype display_name: str + :keyword internal_name: Internal name of the dimension. + :paramtype internal_name: str + :keyword to_be_exported_for_shoebox: To be exported to shoe box. + :paramtype to_be_exported_for_shoebox: bool + """ super(MetricDimension, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -1070,23 +1337,23 @@ def __init__( class MetricSpecification(msrest.serialization.Model): """Details about operation related to metrics. - :param name: The name of the metric. - :type name: str - :param display_name: Localized display name of the metric. - :type display_name: str - :param display_description: The description of the metric. - :type display_description: str - :param unit: The unit that the metric is measured in. - :type unit: str - :param aggregation_type: The type of metric aggregation. - :type aggregation_type: str - :param supported_aggregation_types: Support metric aggregation type. - :type supported_aggregation_types: list[str or + :ivar name: The name of the metric. + :vartype name: str + :ivar display_name: Localized display name of the metric. + :vartype display_name: str + :ivar display_description: The description of the metric. + :vartype display_description: str + :ivar unit: The unit that the metric is measured in. + :vartype unit: str + :ivar aggregation_type: The type of metric aggregation. + :vartype aggregation_type: str + :ivar supported_aggregation_types: Support metric aggregation type. + :vartype supported_aggregation_types: list[str or ~storage_cache_management_client.models.MetricAggregationType] - :param metric_class: Type of metrics. - :type metric_class: str - :param dimensions: Dimensions of the metric. - :type dimensions: list[~storage_cache_management_client.models.MetricDimension] + :ivar metric_class: Type of metrics. + :vartype metric_class: str + :ivar dimensions: Dimensions of the metric. + :vartype dimensions: list[~storage_cache_management_client.models.MetricDimension] """ _attribute_map = { @@ -1113,6 +1380,25 @@ def __init__( dimensions: Optional[List["MetricDimension"]] = None, **kwargs ): + """ + :keyword name: The name of the metric. + :paramtype name: str + :keyword display_name: Localized display name of the metric. + :paramtype display_name: str + :keyword display_description: The description of the metric. + :paramtype display_description: str + :keyword unit: The unit that the metric is measured in. + :paramtype unit: str + :keyword aggregation_type: The type of metric aggregation. + :paramtype aggregation_type: str + :keyword supported_aggregation_types: Support metric aggregation type. + :paramtype supported_aggregation_types: list[str or + ~storage_cache_management_client.models.MetricAggregationType] + :keyword metric_class: Type of metrics. + :paramtype metric_class: str + :keyword dimensions: Dimensions of the metric. + :paramtype dimensions: list[~storage_cache_management_client.models.MetricDimension] + """ super(MetricSpecification, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -1127,14 +1413,14 @@ def __init__( class NamespaceJunction(msrest.serialization.Model): """A namespace junction. - :param namespace_path: Namespace path on a Cache for a Storage Target. - :type namespace_path: str - :param target_path: Path in Storage Target to which namespacePath points. - :type target_path: str - :param nfs_export: NFS export where targetPath exists. - :type nfs_export: str - :param nfs_access_policy: Name of the access policy applied to this junction. - :type nfs_access_policy: str + :ivar namespace_path: Namespace path on a Cache for a Storage Target. + :vartype namespace_path: str + :ivar target_path: Path in Storage Target to which namespacePath points. + :vartype target_path: str + :ivar nfs_export: NFS export where targetPath exists. + :vartype nfs_export: str + :ivar nfs_access_policy: Name of the access policy applied to this junction. + :vartype nfs_access_policy: str """ _attribute_map = { @@ -1153,6 +1439,16 @@ def __init__( nfs_access_policy: Optional[str] = "default", **kwargs ): + """ + :keyword namespace_path: Namespace path on a Cache for a Storage Target. + :paramtype namespace_path: str + :keyword target_path: Path in Storage Target to which namespacePath points. + :paramtype target_path: str + :keyword nfs_export: NFS export where targetPath exists. + :paramtype nfs_export: str + :keyword nfs_access_policy: Name of the access policy applied to this junction. + :paramtype nfs_access_policy: str + """ super(NamespaceJunction, self).__init__(**kwargs) self.namespace_path = namespace_path self.target_path = target_path @@ -1163,10 +1459,10 @@ def __init__( class Nfs3Target(msrest.serialization.Model): """Properties pertaining to the Nfs3Target. - :param target: IP address or host name of an NFSv3 host (e.g., 10.0.44.44). - :type target: str - :param usage_model: Identifies the StorageCache usage model to be used for this storage target. - :type usage_model: str + :ivar target: IP address or host name of an NFSv3 host (e.g., 10.0.44.44). + :vartype target: str + :ivar usage_model: Identifies the StorageCache usage model to be used for this storage target. + :vartype usage_model: str """ _validation = { @@ -1185,6 +1481,13 @@ def __init__( usage_model: Optional[str] = None, **kwargs ): + """ + :keyword target: IP address or host name of an NFSv3 host (e.g., 10.0.44.44). + :paramtype target: str + :keyword usage_model: Identifies the StorageCache usage model to be used for this storage + target. + :paramtype usage_model: str + """ super(Nfs3Target, self).__init__(**kwargs) self.target = target self.usage_model = usage_model @@ -1195,12 +1498,11 @@ class NfsAccessPolicy(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name identifying this policy. Access Policy names are not case - sensitive. - :type name: str - :param access_rules: Required. The set of rules describing client accesses allowed under this + :ivar name: Required. Name identifying this policy. Access Policy names are not case sensitive. + :vartype name: str + :ivar access_rules: Required. The set of rules describing client accesses allowed under this policy. - :type access_rules: list[~storage_cache_management_client.models.NfsAccessRule] + :vartype access_rules: list[~storage_cache_management_client.models.NfsAccessRule] """ _validation = { @@ -1220,6 +1522,14 @@ def __init__( access_rules: List["NfsAccessRule"], **kwargs ): + """ + :keyword name: Required. Name identifying this policy. Access Policy names are not case + sensitive. + :paramtype name: str + :keyword access_rules: Required. The set of rules describing client accesses allowed under this + policy. + :paramtype access_rules: list[~storage_cache_management_client.models.NfsAccessRule] + """ super(NfsAccessPolicy, self).__init__(**kwargs) self.name = name self.access_rules = access_rules @@ -1230,32 +1540,31 @@ class NfsAccessRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param scope: Required. Scope for this rule. The scope and filter determine which clients match + :ivar scope: Required. Scope for this rule. The scope and filter determine which clients match the rule. Possible values include: "default", "network", "host". - :type scope: str or ~storage_cache_management_client.models.NfsAccessRuleScope - :param filter: Filter applied to the scope for this rule. The filter's format depends on its + :vartype scope: str or ~storage_cache_management_client.models.NfsAccessRuleScope + :ivar filter: Filter applied to the scope for this rule. The filter's format depends on its scope. 'default' scope matches all clients and has no filter value. 'network' scope takes a filter in CIDR format (for example, 10.99.1.0/24). 'host' takes an IP address or fully qualified domain name as filter. If a client does not match any filter rule and there is no default rule, access is denied. - :type filter: str - :param access: Required. Access allowed by this rule. Possible values include: "no", "ro", - "rw". - :type access: str or ~storage_cache_management_client.models.NfsAccessRuleAccess - :param suid: Allow SUID semantics. - :type suid: bool - :param submount_access: For the default policy, allow access to subdirectories under the root + :vartype filter: str + :ivar access: Required. Access allowed by this rule. Possible values include: "no", "ro", "rw". + :vartype access: str or ~storage_cache_management_client.models.NfsAccessRuleAccess + :ivar suid: Allow SUID semantics. + :vartype suid: bool + :ivar submount_access: For the default policy, allow access to subdirectories under the root export. If this is set to no, clients can only mount the path '/'. If set to yes, clients can mount a deeper path, like '/a/b'. - :type submount_access: bool - :param root_squash: Map root accesses to anonymousUID and anonymousGID. - :type root_squash: bool - :param anonymous_uid: UID value that replaces 0 when rootSquash is true. 65534 will be used if + :vartype submount_access: bool + :ivar root_squash: Map root accesses to anonymousUID and anonymousGID. + :vartype root_squash: bool + :ivar anonymous_uid: UID value that replaces 0 when rootSquash is true. 65534 will be used if not provided. - :type anonymous_uid: str - :param anonymous_gid: GID value that replaces 0 when rootSquash is true. This will use the - value of anonymousUID if not provided. - :type anonymous_gid: str + :vartype anonymous_uid: str + :ivar anonymous_gid: GID value that replaces 0 when rootSquash is true. This will use the value + of anonymousUID if not provided. + :vartype anonymous_gid: str """ _validation = { @@ -1287,6 +1596,34 @@ def __init__( anonymous_gid: Optional[str] = None, **kwargs ): + """ + :keyword scope: Required. Scope for this rule. The scope and filter determine which clients + match the rule. Possible values include: "default", "network", "host". + :paramtype scope: str or ~storage_cache_management_client.models.NfsAccessRuleScope + :keyword filter: Filter applied to the scope for this rule. The filter's format depends on its + scope. 'default' scope matches all clients and has no filter value. 'network' scope takes a + filter in CIDR format (for example, 10.99.1.0/24). 'host' takes an IP address or fully + qualified domain name as filter. If a client does not match any filter rule and there is no + default rule, access is denied. + :paramtype filter: str + :keyword access: Required. Access allowed by this rule. Possible values include: "no", "ro", + "rw". + :paramtype access: str or ~storage_cache_management_client.models.NfsAccessRuleAccess + :keyword suid: Allow SUID semantics. + :paramtype suid: bool + :keyword submount_access: For the default policy, allow access to subdirectories under the root + export. If this is set to no, clients can only mount the path '/'. If set to yes, clients can + mount a deeper path, like '/a/b'. + :paramtype submount_access: bool + :keyword root_squash: Map root accesses to anonymousUID and anonymousGID. + :paramtype root_squash: bool + :keyword anonymous_uid: UID value that replaces 0 when rootSquash is true. 65534 will be used + if not provided. + :paramtype anonymous_uid: str + :keyword anonymous_gid: GID value that replaces 0 when rootSquash is true. This will use the + value of anonymousUID if not provided. + :paramtype anonymous_gid: str + """ super(NfsAccessRule, self).__init__(**kwargs) self.scope = scope self.filter = filter @@ -1305,18 +1642,18 @@ class ResourceSku(msrest.serialization.Model): :ivar resource_type: The type of resource the SKU applies to. :vartype resource_type: str - :param capabilities: A list of capabilities of this SKU, such as throughput or ops/sec. - :type capabilities: list[~storage_cache_management_client.models.ResourceSkuCapabilities] + :ivar capabilities: A list of capabilities of this SKU, such as throughput or ops/sec. + :vartype capabilities: list[~storage_cache_management_client.models.ResourceSkuCapabilities] :ivar locations: The set of locations where the SKU is available. This is the supported and registered Azure Geo Regions (e.g., West US, East US, Southeast Asia, etc.). :vartype locations: list[str] - :param location_info: The set of locations where the SKU is available. - :type location_info: list[~storage_cache_management_client.models.ResourceSkuLocationInfo] - :param name: The name of this SKU. - :type name: str - :param restrictions: The restrictions preventing this SKU from being used. This is empty if + :ivar location_info: The set of locations where the SKU is available. + :vartype location_info: list[~storage_cache_management_client.models.ResourceSkuLocationInfo] + :ivar name: The name of this SKU. + :vartype name: str + :ivar restrictions: The restrictions preventing this SKU from being used. This is empty if there are no restrictions. - :type restrictions: list[~storage_cache_management_client.models.Restriction] + :vartype restrictions: list[~storage_cache_management_client.models.Restriction] """ _validation = { @@ -1342,6 +1679,17 @@ def __init__( restrictions: Optional[List["Restriction"]] = None, **kwargs ): + """ + :keyword capabilities: A list of capabilities of this SKU, such as throughput or ops/sec. + :paramtype capabilities: list[~storage_cache_management_client.models.ResourceSkuCapabilities] + :keyword location_info: The set of locations where the SKU is available. + :paramtype location_info: list[~storage_cache_management_client.models.ResourceSkuLocationInfo] + :keyword name: The name of this SKU. + :paramtype name: str + :keyword restrictions: The restrictions preventing this SKU from being used. This is empty if + there are no restrictions. + :paramtype restrictions: list[~storage_cache_management_client.models.Restriction] + """ super(ResourceSku, self).__init__(**kwargs) self.resource_type = None self.capabilities = capabilities @@ -1354,10 +1702,10 @@ def __init__( class ResourceSkuCapabilities(msrest.serialization.Model): """A resource SKU capability. - :param name: Name of a capability, such as ops/sec. - :type name: str - :param value: Quantity, if the capability is measured by quantity. - :type value: str + :ivar name: Name of a capability, such as ops/sec. + :vartype name: str + :ivar value: Quantity, if the capability is measured by quantity. + :vartype value: str """ _attribute_map = { @@ -1372,6 +1720,12 @@ def __init__( value: Optional[str] = None, **kwargs ): + """ + :keyword name: Name of a capability, such as ops/sec. + :paramtype name: str + :keyword value: Quantity, if the capability is measured by quantity. + :paramtype value: str + """ super(ResourceSkuCapabilities, self).__init__(**kwargs) self.name = name self.value = value @@ -1380,10 +1734,10 @@ def __init__( class ResourceSkuLocationInfo(msrest.serialization.Model): """Resource SKU location information. - :param location: Location where this SKU is available. - :type location: str - :param zones: Zones if any. - :type zones: list[str] + :ivar location: Location where this SKU is available. + :vartype location: str + :ivar zones: Zones if any. + :vartype zones: list[str] """ _attribute_map = { @@ -1398,6 +1752,12 @@ def __init__( zones: Optional[List[str]] = None, **kwargs ): + """ + :keyword location: Location where this SKU is available. + :paramtype location: str + :keyword zones: Zones if any. + :paramtype zones: list[str] + """ super(ResourceSkuLocationInfo, self).__init__(**kwargs) self.location = location self.zones = zones @@ -1408,8 +1768,8 @@ class ResourceSkusResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param next_link: The URI to fetch the next page of Cache SKUs. - :type next_link: str + :ivar next_link: The URI to fetch the next page of Cache SKUs. + :vartype next_link: str :ivar value: The list of SKUs available for the subscription. :vartype value: list[~storage_cache_management_client.models.ResourceSku] """ @@ -1429,11 +1789,122 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: The URI to fetch the next page of Cache SKUs. + :paramtype next_link: str + """ super(ResourceSkusResult, self).__init__(**kwargs) self.next_link = next_link self.value = None +class ResourceUsage(msrest.serialization.Model): + """The usage and limit (quota) for a resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar limit: The limit (quota) for this resource. + :vartype limit: int + :ivar unit: Unit that the limit and usages are expressed in, such as 'Count'. + :vartype unit: str + :ivar current_value: The current usage of this resource. + :vartype current_value: int + :ivar name: Naming information for this resource type. + :vartype name: ~storage_cache_management_client.models.ResourceUsageName + """ + + _validation = { + 'limit': {'readonly': True, 'minimum': 0}, + 'unit': {'readonly': True}, + 'current_value': {'readonly': True, 'minimum': 0}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'limit': {'key': 'limit', 'type': 'int'}, + 'unit': {'key': 'unit', 'type': 'str'}, + 'current_value': {'key': 'currentValue', 'type': 'int'}, + 'name': {'key': 'name', 'type': 'ResourceUsageName'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ResourceUsage, self).__init__(**kwargs) + self.limit = None + self.unit = None + self.current_value = None + self.name = None + + +class ResourceUsageName(msrest.serialization.Model): + """Naming information for this resource type. + + :ivar value: Canonical name for this resource type. + :vartype value: str + :ivar localized_value: Localized name for this resource type. + :vartype localized_value: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': 'str'}, + 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[str] = None, + localized_value: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Canonical name for this resource type. + :paramtype value: str + :keyword localized_value: Localized name for this resource type. + :paramtype localized_value: str + """ + super(ResourceUsageName, self).__init__(**kwargs) + self.value = value + self.localized_value = localized_value + + +class ResourceUsagesListResult(msrest.serialization.Model): + """Result of the request to list resource usages. It contains a list of resource usages & limits and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar next_link: URL to get the next set of resource usage list results if there are any. + :vartype next_link: str + :ivar value: List of usages and limits for resources controlled by the Microsoft.StorageCache + resource provider. + :vartype value: list[~storage_cache_management_client.models.ResourceUsage] + """ + + _validation = { + 'next_link': {'readonly': True}, + 'value': {'readonly': True}, + } + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[ResourceUsage]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ResourceUsagesListResult, self).__init__(**kwargs) + self.next_link = None + self.value = None + + class Restriction(msrest.serialization.Model): """The restrictions preventing this SKU from being used. @@ -1445,11 +1916,11 @@ class Restriction(msrest.serialization.Model): :ivar values: The value of restrictions. If the restriction type is set to location, then this would be the different locations where the SKU is restricted. :vartype values: list[str] - :param reason_code: The reason for the restriction. As of now this can be "QuotaId" or + :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". "QuotaId" is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. "NotAvailableForSubscription" is related to capacity at the datacenter. Possible values include: "QuotaId", "NotAvailableForSubscription". - :type reason_code: str or ~storage_cache_management_client.models.ReasonCode + :vartype reason_code: str or ~storage_cache_management_client.models.ReasonCode """ _validation = { @@ -1469,6 +1940,13 @@ def __init__( reason_code: Optional[Union[str, "ReasonCode"]] = None, **kwargs ): + """ + :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or + "NotAvailableForSubscription". "QuotaId" is set when the SKU has requiredQuotas parameter as + the subscription does not belong to that quota. "NotAvailableForSubscription" is related to + capacity at the datacenter. Possible values include: "QuotaId", "NotAvailableForSubscription". + :paramtype reason_code: str or ~storage_cache_management_client.models.ReasonCode + """ super(Restriction, self).__init__(**kwargs) self.type = None self.values = None @@ -1512,6 +1990,8 @@ def __init__( self, **kwargs ): + """ + """ super(StorageTargetResource, self).__init__(**kwargs) self.name = None self.id = None @@ -1535,28 +2015,28 @@ class StorageTarget(StorageTargetResource): :vartype location: str :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~storage_cache_management_client.models.SystemData - :param junctions: List of Cache namespace junctions to target for namespace associations. - :type junctions: list[~storage_cache_management_client.models.NamespaceJunction] - :param target_type: Type of the Storage Target. Possible values include: "nfs3", "clfs", + :ivar junctions: List of Cache namespace junctions to target for namespace associations. + :vartype junctions: list[~storage_cache_management_client.models.NamespaceJunction] + :ivar target_type: Type of the Storage Target. Possible values include: "nfs3", "clfs", "unknown", "blobNfs". - :type target_type: str or ~storage_cache_management_client.models.StorageTargetType + :vartype target_type: str or ~storage_cache_management_client.models.StorageTargetType :ivar provisioning_state: ARM provisioning state, see https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. Possible values include: "Succeeded", "Failed", "Cancelled", "Creating", "Deleting", "Updating". :vartype provisioning_state: str or ~storage_cache_management_client.models.ProvisioningStateType - :param state: Storage target operational state. Possible values include: "Ready", "Busy", + :ivar state: Storage target operational state. Possible values include: "Ready", "Busy", "Suspended", "Flushing". - :type state: str or ~storage_cache_management_client.models.OperationalStateType - :param nfs3: Properties when targetType is nfs3. - :type nfs3: ~storage_cache_management_client.models.Nfs3Target - :param clfs: Properties when targetType is clfs. - :type clfs: ~storage_cache_management_client.models.ClfsTarget - :param unknown: Properties when targetType is unknown. - :type unknown: ~storage_cache_management_client.models.UnknownTarget - :param blob_nfs: Properties when targetType is blobNfs. - :type blob_nfs: ~storage_cache_management_client.models.BlobNfsTarget + :vartype state: str or ~storage_cache_management_client.models.OperationalStateType + :ivar nfs3: Properties when targetType is nfs3. + :vartype nfs3: ~storage_cache_management_client.models.Nfs3Target + :ivar clfs: Properties when targetType is clfs. + :vartype clfs: ~storage_cache_management_client.models.ClfsTarget + :ivar unknown: Properties when targetType is unknown. + :vartype unknown: ~storage_cache_management_client.models.UnknownTarget + :ivar blob_nfs: Properties when targetType is blobNfs. + :vartype blob_nfs: ~storage_cache_management_client.models.BlobNfsTarget """ _validation = { @@ -1596,6 +2076,24 @@ def __init__( blob_nfs: Optional["BlobNfsTarget"] = None, **kwargs ): + """ + :keyword junctions: List of Cache namespace junctions to target for namespace associations. + :paramtype junctions: list[~storage_cache_management_client.models.NamespaceJunction] + :keyword target_type: Type of the Storage Target. Possible values include: "nfs3", "clfs", + "unknown", "blobNfs". + :paramtype target_type: str or ~storage_cache_management_client.models.StorageTargetType + :keyword state: Storage target operational state. Possible values include: "Ready", "Busy", + "Suspended", "Flushing". + :paramtype state: str or ~storage_cache_management_client.models.OperationalStateType + :keyword nfs3: Properties when targetType is nfs3. + :paramtype nfs3: ~storage_cache_management_client.models.Nfs3Target + :keyword clfs: Properties when targetType is clfs. + :paramtype clfs: ~storage_cache_management_client.models.ClfsTarget + :keyword unknown: Properties when targetType is unknown. + :paramtype unknown: ~storage_cache_management_client.models.UnknownTarget + :keyword blob_nfs: Properties when targetType is blobNfs. + :paramtype blob_nfs: ~storage_cache_management_client.models.BlobNfsTarget + """ super(StorageTarget, self).__init__(**kwargs) self.junctions = junctions self.target_type = target_type @@ -1610,10 +2108,10 @@ def __init__( class StorageTargetsResult(msrest.serialization.Model): """A list of Storage Targets. - :param next_link: The URI to fetch the next page of Storage Targets. - :type next_link: str - :param value: The list of Storage Targets defined for the Cache. - :type value: list[~storage_cache_management_client.models.StorageTarget] + :ivar next_link: The URI to fetch the next page of Storage Targets. + :vartype next_link: str + :ivar value: The list of Storage Targets defined for the Cache. + :vartype value: list[~storage_cache_management_client.models.StorageTarget] """ _attribute_map = { @@ -1628,6 +2126,12 @@ def __init__( value: Optional[List["StorageTarget"]] = None, **kwargs ): + """ + :keyword next_link: The URI to fetch the next page of Storage Targets. + :paramtype next_link: str + :keyword value: The list of Storage Targets defined for the Cache. + :paramtype value: list[~storage_cache_management_client.models.StorageTarget] + """ super(StorageTargetsResult, self).__init__(**kwargs) self.next_link = next_link self.value = value @@ -1636,20 +2140,20 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~storage_cache_management_client.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~storage_cache_management_client.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~storage_cache_management_client.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :vartype last_modified_by_type: str or ~storage_cache_management_client.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -1672,6 +2176,22 @@ def __init__( last_modified_at: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~storage_cache_management_client.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~storage_cache_management_client.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ super(SystemData, self).__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type @@ -1684,9 +2204,9 @@ def __init__( class UnknownTarget(msrest.serialization.Model): """Properties pertaining to the UnknownTarget. - :param attributes: Dictionary of string->string pairs containing information about the Storage + :ivar attributes: Dictionary of string->string pairs containing information about the Storage Target. - :type attributes: dict[str, str] + :vartype attributes: dict[str, str] """ _attribute_map = { @@ -1699,6 +2219,11 @@ def __init__( attributes: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword attributes: Dictionary of string->string pairs containing information about the + Storage Target. + :paramtype attributes: dict[str, str] + """ super(UnknownTarget, self).__init__(**kwargs) self.attributes = attributes @@ -1706,13 +2231,13 @@ def __init__( class UsageModel(msrest.serialization.Model): """A usage model. - :param display: Localized information describing this usage model. - :type display: ~storage_cache_management_client.models.UsageModelDisplay - :param model_name: Non-localized keyword name for this usage model. - :type model_name: str - :param target_type: The type of Storage Target to which this model is applicable (only nfs3 as + :ivar display: Localized information describing this usage model. + :vartype display: ~storage_cache_management_client.models.UsageModelDisplay + :ivar model_name: Non-localized keyword name for this usage model. + :vartype model_name: str + :ivar target_type: The type of Storage Target to which this model is applicable (only nfs3 as of this version). - :type target_type: str + :vartype target_type: str """ _attribute_map = { @@ -1729,6 +2254,15 @@ def __init__( target_type: Optional[str] = None, **kwargs ): + """ + :keyword display: Localized information describing this usage model. + :paramtype display: ~storage_cache_management_client.models.UsageModelDisplay + :keyword model_name: Non-localized keyword name for this usage model. + :paramtype model_name: str + :keyword target_type: The type of Storage Target to which this model is applicable (only nfs3 + as of this version). + :paramtype target_type: str + """ super(UsageModel, self).__init__(**kwargs) self.display = display self.model_name = model_name @@ -1738,8 +2272,8 @@ def __init__( class UsageModelDisplay(msrest.serialization.Model): """Localized information describing this usage model. - :param description: String to display for this usage model. - :type description: str + :ivar description: String to display for this usage model. + :vartype description: str """ _attribute_map = { @@ -1752,6 +2286,10 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword description: String to display for this usage model. + :paramtype description: str + """ super(UsageModelDisplay, self).__init__(**kwargs) self.description = description @@ -1759,10 +2297,10 @@ def __init__( class UsageModelsResult(msrest.serialization.Model): """A list of Cache usage models. - :param next_link: The URI to fetch the next page of Cache usage models. - :type next_link: str - :param value: The list of usage models available for the subscription. - :type value: list[~storage_cache_management_client.models.UsageModel] + :ivar next_link: The URI to fetch the next page of Cache usage models. + :vartype next_link: str + :ivar value: The list of usage models available for the subscription. + :vartype value: list[~storage_cache_management_client.models.UsageModel] """ _attribute_map = { @@ -1777,6 +2315,12 @@ def __init__( value: Optional[List["UsageModel"]] = None, **kwargs ): + """ + :keyword next_link: The URI to fetch the next page of Cache usage models. + :paramtype next_link: str + :keyword value: The list of usage models available for the subscription. + :paramtype value: list[~storage_cache_management_client.models.UsageModel] + """ super(UsageModelsResult, self).__init__(**kwargs) self.next_link = next_link self.value = value @@ -1807,6 +2351,8 @@ def __init__( self, **kwargs ): + """ + """ super(UserAssignedIdentitiesValue, self).__init__(**kwargs) self.principal_id = None self.client_id = None diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/models/_storage_cache_management_client_enums.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/models/_storage_cache_management_client_enums.py index 5ac4021707e28..da3ba535a618c 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/models/_storage_cache_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/models/_storage_cache_management_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class CacheIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CacheIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity used for the cache """ @@ -35,7 +20,7 @@ class CacheIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -44,7 +29,7 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DomainJoinedType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DomainJoinedType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """True if the HPC Cache is joined to the Active Directory domain. """ @@ -52,7 +37,7 @@ class DomainJoinedType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): NO = "No" ERROR = "Error" -class FirmwareStatusType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class FirmwareStatusType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """True if there is a firmware update ready to install on this Cache. The firmware will automatically be installed after firmwareUpdateDeadline if not triggered earlier via the upgrade operation. @@ -61,7 +46,7 @@ class FirmwareStatusType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): AVAILABLE = "available" UNAVAILABLE = "unavailable" -class HealthStateType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class HealthStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """List of Cache health states. """ @@ -75,7 +60,7 @@ class HealthStateType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UPGRADING = "Upgrading" FLUSHING = "Flushing" -class MetricAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MetricAggregationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NOT_SPECIFIED = "NotSpecified" NONE = "None" @@ -85,7 +70,7 @@ class MetricAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) TOTAL = "Total" COUNT = "Count" -class NfsAccessRuleAccess(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NfsAccessRuleAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Access allowed by this rule. """ @@ -93,7 +78,7 @@ class NfsAccessRuleAccess(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RO = "ro" RW = "rw" -class NfsAccessRuleScope(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NfsAccessRuleScope(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Scope for this rule. The scope and filter determine which clients match the rule. """ @@ -101,7 +86,7 @@ class NfsAccessRuleScope(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): NETWORK = "network" HOST = "host" -class OperationalStateType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OperationalStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Storage target operational state. """ @@ -110,7 +95,7 @@ class OperationalStateType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SUSPENDED = "Suspended" FLUSHING = "Flushing" -class ProvisioningStateType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """ARM provisioning state, see https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property """ @@ -122,7 +107,7 @@ class ProvisioningStateType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) DELETING = "Deleting" UPDATING = "Updating" -class ReasonCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". "QuotaId" is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. "NotAvailableForSubscription" is related to @@ -132,7 +117,7 @@ class ReasonCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class StorageTargetType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class StorageTargetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of the Storage Target. """ @@ -141,7 +126,7 @@ class StorageTargetType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UNKNOWN = "unknown" BLOB_NFS = "blobNfs" -class UsernameDownloadedType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class UsernameDownloadedType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Indicates whether or not the HPC Cache has performed the username download successfully. """ @@ -149,7 +134,7 @@ class UsernameDownloadedType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum) NO = "No" ERROR = "Error" -class UsernameSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class UsernameSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """This setting determines how the cache gets username and group names for clients. """ diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/__init__.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/__init__.py index f20bf4cd94a14..9bcdf38cf5116 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/__init__.py @@ -10,6 +10,7 @@ from ._skus_operations import SkusOperations from ._usage_models_operations import UsageModelsOperations from ._asc_operations_operations import AscOperationsOperations +from ._asc_usages_operations import AscUsagesOperations from ._caches_operations import CachesOperations from ._storage_targets_operations import StorageTargetsOperations from ._storage_target_operations import StorageTargetOperations @@ -19,6 +20,7 @@ 'SkusOperations', 'UsageModelsOperations', 'AscOperationsOperations', + 'AscUsagesOperations', 'CachesOperations', 'StorageTargetsOperations', 'StorageTargetOperations', diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_asc_operations_operations.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_asc_operations_operations.py index b8409f97c5967..4c7fdcae3052d 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_asc_operations_operations.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_asc_operations_operations.py @@ -5,22 +5,59 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + location: str, + operation_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/locations/{location}/ascOperations/{operationId}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "location": _SERIALIZER.url("location", location, 'str'), + "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AscOperationsOperations(object): """AscOperationsOperations operations. @@ -44,13 +81,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - location, # type: str - operation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AscOperation" + location: str, + operation_id: str, + **kwargs: Any + ) -> "_models.AscOperation": """Gets the status of an asynchronous operation for the Azure HPC Cache. :param location: The name of the region used to look up the operation. @@ -67,27 +104,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'location': self._serialize.url("location", location, 'str'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + location=location, + operation_id=operation_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,4 +128,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/locations/{location}/ascOperations/{operationId}'} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_asc_usages_operations.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_asc_usages_operations.py new file mode 100644 index 0000000000000..7d1b5ca6d3507 --- /dev/null +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_asc_usages_operations.py @@ -0,0 +1,151 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + location: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/locations/{location}/usages') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "location": _SERIALIZER.url("location", location, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class AscUsagesOperations(object): + """AscUsagesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~storage_cache_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + location: str, + **kwargs: Any + ) -> Iterable["_models.ResourceUsagesListResult"]: + """Gets the quantity used and quota limit for resources. + + :param location: The name of the region to query for usage information. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceUsagesListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~storage_cache_management_client.models.ResourceUsagesListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUsagesListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ResourceUsagesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/locations/{location}/usages'} # type: ignore diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_caches_operations.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_caches_operations.py index 82db0b3210c8e..6c779ba3f8f97 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_caches_operations.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_caches_operations.py @@ -5,25 +5,425 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/caches') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + cache_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cacheName": _SERIALIZER.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + cache_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cacheName": _SERIALIZER.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + subscription_id: str, + cache_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "cacheName": _SERIALIZER.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + subscription_id: str, + cache_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "cacheName": _SERIALIZER.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_debug_info_request_initial( + resource_group_name: str, + subscription_id: str, + cache_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/debugInfo') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "cacheName": _SERIALIZER.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_flush_request_initial( + resource_group_name: str, + subscription_id: str, + cache_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/flush') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "cacheName": _SERIALIZER.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_start_request_initial( + resource_group_name: str, + subscription_id: str, + cache_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/start') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "cacheName": _SERIALIZER.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_stop_request_initial( + resource_group_name: str, + subscription_id: str, + cache_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/stop') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "cacheName": _SERIALIZER.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_upgrade_firmware_request_initial( + resource_group_name: str, + subscription_id: str, + cache_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/upgrade') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "cacheName": _SERIALIZER.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class CachesOperations(object): """CachesOperations operations. @@ -47,11 +447,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.CachesListResult"] + **kwargs: Any + ) -> Iterable["_models.CachesListResult"]: """Returns all Caches the user has access to under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -64,34 +464,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('CachesListResult', pipeline_response) + deserialized = self._deserialize("CachesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,17 +504,18 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/caches'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.CachesListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.CachesListResult"]: """Returns all Caches the user has access to under a resource group. :param resource_group_name: Target resource group. @@ -134,35 +530,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('CachesListResult', pipeline_response) + deserialized = self._deserialize("CachesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -180,6 +572,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -187,37 +580,26 @@ def get_next(next_link=None): def _delete_initial( self, - resource_group_name, # type: str - cache_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + cache_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + cache_name=cache_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -230,13 +612,14 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - cache_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cache_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Schedules a Cache for deletion. :param resource_group_name: Target resource group. @@ -246,15 +629,17 @@ def begin_delete( :type cache_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -268,21 +653,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -294,15 +672,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - cache_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Cache" + resource_group_name: str, + cache_name: str, + **kwargs: Any + ) -> "_models.Cache": """Returns a Cache. :param resource_group_name: Target resource group. @@ -320,27 +699,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + cache_name=cache_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -354,50 +723,41 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - cache_name, # type: str - cache=None, # type: Optional["_models.Cache"] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Cache"] + resource_group_name: str, + cache_name: str, + cache: Optional["_models.Cache"] = None, + **kwargs: Any + ) -> Optional["_models.Cache"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Cache"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if cache is not None: - body_content = self._serialize.body(cache, 'Cache') + _json = self._serialize.body(cache, 'Cache') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -416,16 +776,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - cache_name, # type: str - cache=None, # type: Optional["_models.Cache"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Cache"] + resource_group_name: str, + cache_name: str, + cache: Optional["_models.Cache"] = None, + **kwargs: Any + ) -> LROPoller["_models.Cache"]: """Create or update a Cache. :param resource_group_name: Target resource group. @@ -438,15 +800,18 @@ def begin_create_or_update( :type cache: ~storage_cache_management_client.models.Cache :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Cache or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~storage_cache_management_client.models.Cache] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Cache"] lro_delay = kwargs.pop( 'polling_interval', @@ -458,27 +823,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, cache_name=cache_name, cache=cache, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Cache', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -490,16 +849,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} # type: ignore + @distributed_trace def update( self, - resource_group_name, # type: str - cache_name, # type: str - cache=None, # type: Optional["_models.Cache"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Cache" + resource_group_name: str, + cache_name: str, + cache: Optional["_models.Cache"] = None, + **kwargs: Any + ) -> "_models.Cache": """Update a Cache instance. :param resource_group_name: Target resource group. @@ -520,35 +880,25 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if cache is not None: - body_content = self._serialize.body(cache, 'Cache') + _json = self._serialize.body(cache, 'Cache') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -562,41 +912,32 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} # type: ignore + def _debug_info_initial( self, - resource_group_name, # type: str - cache_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + cache_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self._debug_info_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_debug_info_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + template_url=self._debug_info_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -609,13 +950,14 @@ def _debug_info_initial( _debug_info_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/debugInfo'} # type: ignore + + @distributed_trace def begin_debug_info( self, - resource_group_name, # type: str - cache_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cache_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Tells a Cache to write generate debug info for support to process. :param resource_group_name: Target resource group. @@ -625,15 +967,17 @@ def begin_debug_info( :type cache_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -647,21 +991,14 @@ def begin_debug_info( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -673,41 +1010,31 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_debug_info.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/debugInfo'} # type: ignore def _flush_initial( self, - resource_group_name, # type: str - cache_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + cache_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self._flush_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_flush_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + template_url=self._flush_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -720,13 +1047,14 @@ def _flush_initial( _flush_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/flush'} # type: ignore + + @distributed_trace def begin_flush( self, - resource_group_name, # type: str - cache_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cache_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Tells a Cache to write all dirty data to the Storage Target(s). During the flush, clients will see errors returned until the flush is complete. @@ -737,15 +1065,17 @@ def begin_flush( :type cache_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -759,21 +1089,14 @@ def begin_flush( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -785,41 +1108,31 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_flush.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/flush'} # type: ignore def _start_initial( self, - resource_group_name, # type: str - cache_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + cache_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self._start_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_start_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + template_url=self._start_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -832,13 +1145,14 @@ def _start_initial( _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/start'} # type: ignore + + @distributed_trace def begin_start( self, - resource_group_name, # type: str - cache_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cache_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Tells a Stopped state Cache to transition to Active state. :param resource_group_name: Target resource group. @@ -848,15 +1162,17 @@ def begin_start( :type cache_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -870,21 +1186,14 @@ def begin_start( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -896,41 +1205,31 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/start'} # type: ignore def _stop_initial( self, - resource_group_name, # type: str - cache_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + cache_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self._stop_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_stop_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + template_url=self._stop_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -943,13 +1242,14 @@ def _stop_initial( _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/stop'} # type: ignore + + @distributed_trace def begin_stop( self, - resource_group_name, # type: str - cache_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cache_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Tells an Active Cache to transition to Stopped state. :param resource_group_name: Target resource group. @@ -959,15 +1259,17 @@ def begin_stop( :type cache_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -981,21 +1283,14 @@ def begin_stop( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1007,41 +1302,31 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/stop'} # type: ignore def _upgrade_firmware_initial( self, - resource_group_name, # type: str - cache_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + cache_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self._upgrade_firmware_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_upgrade_firmware_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + template_url=self._upgrade_firmware_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1054,13 +1339,14 @@ def _upgrade_firmware_initial( _upgrade_firmware_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/upgrade'} # type: ignore + + @distributed_trace def begin_upgrade_firmware( self, - resource_group_name, # type: str - cache_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cache_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Upgrade a Cache's firmware if a new version is available. Otherwise, this operation has no effect. @@ -1071,15 +1357,17 @@ def begin_upgrade_firmware( :type cache_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1093,21 +1381,14 @@ def begin_upgrade_firmware( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1119,4 +1400,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_upgrade_firmware.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/upgrade'} # type: ignore diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_operations.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_operations.py index fc9b3e826608c..f0ef66183e934 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_operations.py @@ -5,23 +5,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.StorageCache/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,16 +72,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ApiOperationListResult"] + **kwargs: Any + ) -> Iterable["_models.ApiOperationListResult"]: """Lists all of the available Resource Provider operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApiOperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~storage_cache_management_client.models.ApiOperationListResult] + :return: An iterator like instance of either ApiOperationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~storage_cache_management_client.models.ApiOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiOperationListResult"] @@ -62,30 +91,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApiOperationListResult', pipeline_response) + deserialized = self._deserialize("ApiOperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +129,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_skus_operations.py index 32ec238ca5a26..79960b4415588 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_skus_operations.py @@ -5,23 +5,56 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/skus') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class SkusOperations(object): """SkusOperations operations. @@ -45,16 +78,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ResourceSkusResult"] + **kwargs: Any + ) -> Iterable["_models.ResourceSkusResult"]: """Get the list of StorageCache.Cache SKUs available to this subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceSkusResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~storage_cache_management_client.models.ResourceSkusResult] + :rtype: + ~azure.core.paging.ItemPaged[~storage_cache_management_client.models.ResourceSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkusResult"] @@ -62,34 +96,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ResourceSkusResult', pipeline_response) + deserialized = self._deserialize("ResourceSkusResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -107,6 +136,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_storage_target_operations.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_storage_target_operations.py index f692a9f7a6102..7d8a2ad0d1aae 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_storage_target_operations.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_storage_target_operations.py @@ -5,24 +5,174 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_flush_request_initial( + resource_group_name: str, + subscription_id: str, + cache_name: str, + storage_target_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/flush') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "cacheName": _SERIALIZER.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + "storageTargetName": _SERIALIZER.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_suspend_request_initial( + resource_group_name: str, + subscription_id: str, + cache_name: str, + storage_target_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/suspend') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "cacheName": _SERIALIZER.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + "storageTargetName": _SERIALIZER.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_resume_request_initial( + resource_group_name: str, + subscription_id: str, + cache_name: str, + storage_target_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/resume') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "cacheName": _SERIALIZER.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + "storageTargetName": _SERIALIZER.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_invalidate_request_initial( + resource_group_name: str, + subscription_id: str, + cache_name: str, + storage_target_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/invalidate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "cacheName": _SERIALIZER.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + "storageTargetName": _SERIALIZER.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class StorageTargetOperations(object): """StorageTargetOperations operations. @@ -48,39 +198,28 @@ def __init__(self, client, config, serializer, deserializer): def _flush_initial( self, - resource_group_name, # type: str - cache_name, # type: str - storage_target_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + cache_name: str, + storage_target_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self._flush_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_flush_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + storage_target_name=storage_target_name, + template_url=self._flush_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -93,14 +232,15 @@ def _flush_initial( _flush_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/flush'} # type: ignore + + @distributed_trace def begin_flush( self, - resource_group_name, # type: str - cache_name, # type: str - storage_target_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cache_name: str, + storage_target_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Tells the cache to write all dirty data to the Storage Target's backend storage. Client requests to this storage target's namespace will return errors until the flush operation completes. @@ -114,15 +254,17 @@ def begin_flush( :type storage_target_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -137,22 +279,14 @@ def begin_flush( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -164,43 +298,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_flush.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/flush'} # type: ignore def _suspend_initial( self, - resource_group_name, # type: str - cache_name, # type: str - storage_target_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + cache_name: str, + storage_target_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self._suspend_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_suspend_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + storage_target_name=storage_target_name, + template_url=self._suspend_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -213,14 +337,15 @@ def _suspend_initial( _suspend_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/suspend'} # type: ignore + + @distributed_trace def begin_suspend( self, - resource_group_name, # type: str - cache_name, # type: str - storage_target_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cache_name: str, + storage_target_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Suspends client access to a storage target. :param resource_group_name: Target resource group. @@ -232,15 +357,17 @@ def begin_suspend( :type storage_target_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -255,22 +382,14 @@ def begin_suspend( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -282,43 +401,33 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_suspend.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/suspend'} # type: ignore def _resume_initial( self, - resource_group_name, # type: str - cache_name, # type: str - storage_target_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + cache_name: str, + storage_target_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self._resume_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_resume_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + storage_target_name=storage_target_name, + template_url=self._resume_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -331,14 +440,15 @@ def _resume_initial( _resume_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/resume'} # type: ignore + + @distributed_trace def begin_resume( self, - resource_group_name, # type: str - cache_name, # type: str - storage_target_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cache_name: str, + storage_target_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Resumes client access to a previously suspended storage target. :param resource_group_name: Target resource group. @@ -350,15 +460,17 @@ def begin_resume( :type storage_target_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -373,22 +485,14 @@ def begin_resume( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -400,4 +504,109 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_resume.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/resume'} # type: ignore + + def _invalidate_initial( + self, + resource_group_name: str, + cache_name: str, + storage_target_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_invalidate_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + storage_target_name=storage_target_name, + template_url=self._invalidate_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _invalidate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/invalidate'} # type: ignore + + + @distributed_trace + def begin_invalidate( + self, + resource_group_name: str, + cache_name: str, + storage_target_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Invalidate all cached data for a storage target. Cached files are discarded and fetched from + the back end on the next request. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must not be greater than 80 and chars must be + from the [-0-9a-zA-Z_] char class. + :type cache_name: str + :param storage_target_name: Name of Storage Target. + :type storage_target_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._invalidate_initial( + resource_group_name=resource_group_name, + cache_name=cache_name, + storage_target_name=storage_target_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_invalidate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/invalidate'} # type: ignore diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_storage_targets_operations.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_storage_targets_operations.py index 54acd6315762f..7834a3efc91cf 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_storage_targets_operations.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_storage_targets_operations.py @@ -5,25 +5,224 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_dns_refresh_request_initial( + resource_group_name: str, + subscription_id: str, + cache_name: str, + storage_target_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/dnsRefresh') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "cacheName": _SERIALIZER.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + "storageTargetName": _SERIALIZER.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_cache_request( + resource_group_name: str, + subscription_id: str, + cache_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "cacheName": _SERIALIZER.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + subscription_id: str, + cache_name: str, + storage_target_name: str, + *, + force: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "cacheName": _SERIALIZER.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + "storageTargetName": _SERIALIZER.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if force is not None: + query_parameters['force'] = _SERIALIZER.query("force", force, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + subscription_id: str, + cache_name: str, + storage_target_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "cacheName": _SERIALIZER.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + "storageTargetName": _SERIALIZER.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + subscription_id: str, + cache_name: str, + storage_target_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "cacheName": _SERIALIZER.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + "storageTargetName": _SERIALIZER.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class StorageTargetsOperations(object): """StorageTargetsOperations operations. @@ -49,39 +248,28 @@ def __init__(self, client, config, serializer, deserializer): def _dns_refresh_initial( self, - resource_group_name, # type: str - cache_name, # type: str - storage_target_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + cache_name: str, + storage_target_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self._dns_refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_dns_refresh_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + storage_target_name=storage_target_name, + template_url=self._dns_refresh_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -94,14 +282,15 @@ def _dns_refresh_initial( _dns_refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/dnsRefresh'} # type: ignore + + @distributed_trace def begin_dns_refresh( self, - resource_group_name, # type: str - cache_name, # type: str - storage_target_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cache_name: str, + storage_target_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Tells a storage target to refresh its DNS information. :param resource_group_name: Target resource group. @@ -113,15 +302,17 @@ def begin_dns_refresh( :type storage_target_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -136,22 +327,14 @@ def begin_dns_refresh( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -163,15 +346,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_dns_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/dnsRefresh'} # type: ignore + @distributed_trace def list_by_cache( self, - resource_group_name, # type: str - cache_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.StorageTargetsResult"] + resource_group_name: str, + cache_name: str, + **kwargs: Any + ) -> Iterable["_models.StorageTargetsResult"]: """Returns a list of Storage Targets for the specified Cache. :param resource_group_name: Target resource group. @@ -180,8 +364,10 @@ def list_by_cache( from the [-0-9a-zA-Z_] char class. :type cache_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageTargetsResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~storage_cache_management_client.models.StorageTargetsResult] + :return: An iterator like instance of either StorageTargetsResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~storage_cache_management_client.models.StorageTargetsResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageTargetsResult"] @@ -189,36 +375,33 @@ def list_by_cache( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_cache.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_cache_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + template_url=self.list_by_cache.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_cache_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('StorageTargetsResult', pipeline_response) + deserialized = self._deserialize("StorageTargetsResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -236,6 +419,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -243,42 +427,30 @@ def get_next(next_link=None): def _delete_initial( self, - resource_group_name, # type: str - cache_name, # type: str - storage_target_name, # type: str - force=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + cache_name: str, + storage_target_name: str, + force: Optional[str] = None, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + storage_target_name=storage_target_name, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -291,15 +463,16 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - cache_name, # type: str - storage_target_name, # type: str - force=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cache_name: str, + storage_target_name: str, + force: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[None]: """Removes a Storage Target from a Cache. This operation is allowed at any time, but if the Cache is down or unhealthy, the actual removal of the Storage Target may be delayed until the Cache is healthy again. Note that if the Cache has data to flush to the Storage Target, the data will @@ -317,15 +490,17 @@ def begin_delete( :type force: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -341,22 +516,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -368,16 +535,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - cache_name, # type: str - storage_target_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.StorageTarget" + resource_group_name: str, + cache_name: str, + storage_target_name: str, + **kwargs: Any + ) -> "_models.StorageTarget": """Returns a Storage Target from a Cache. :param resource_group_name: Target resource group. @@ -397,28 +565,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + storage_target_name=storage_target_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -432,52 +590,43 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - cache_name, # type: str - storage_target_name, # type: str - storagetarget=None, # type: Optional["_models.StorageTarget"] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.StorageTarget"] + resource_group_name: str, + cache_name: str, + storage_target_name: str, + storagetarget: Optional["_models.StorageTarget"] = None, + **kwargs: Any + ) -> Optional["_models.StorageTarget"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageTarget"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if storagetarget is not None: - body_content = self._serialize.body(storagetarget, 'StorageTarget') + _json = self._serialize.body(storagetarget, 'StorageTarget') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + cache_name=cache_name, + storage_target_name=storage_target_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -496,17 +645,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - cache_name, # type: str - storage_target_name, # type: str - storagetarget=None, # type: Optional["_models.StorageTarget"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.StorageTarget"] + resource_group_name: str, + cache_name: str, + storage_target_name: str, + storagetarget: Optional["_models.StorageTarget"] = None, + **kwargs: Any + ) -> LROPoller["_models.StorageTarget"]: """Create or update a Storage Target. This operation is allowed at any time, but if the Cache is down or unhealthy, the actual creation/modification of the Storage Target may be delayed until the Cache is healthy again. @@ -522,15 +673,19 @@ def begin_create_or_update( :type storagetarget: ~storage_cache_management_client.models.StorageTarget :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either StorageTarget or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageTarget or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~storage_cache_management_client.models.StorageTarget] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageTarget"] lro_delay = kwargs.pop( 'polling_interval', @@ -543,28 +698,21 @@ def begin_create_or_update( cache_name=cache_name, storage_target_name=storage_target_name, storagetarget=storagetarget, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('StorageTarget', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -576,4 +724,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}'} # type: ignore diff --git a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_usage_models_operations.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_usage_models_operations.py index f2665a0cf947a..b5ce80e10d519 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_usage_models_operations.py +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_usage_models_operations.py @@ -5,23 +5,56 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/usageModels') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class UsageModelsOperations(object): """UsageModelsOperations operations. @@ -45,11 +78,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.UsageModelsResult"] + **kwargs: Any + ) -> Iterable["_models.UsageModelsResult"]: """Get the list of Cache Usage Models available to this subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,34 +95,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('UsageModelsResult', pipeline_response) + deserialized = self._deserialize("UsageModelsResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -107,6 +135,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data )