diff --git a/sdk/storage/azure-mgmt-storagecache/_meta.json b/sdk/storage/azure-mgmt-storagecache/_meta.json index 412444d4809a..51b1d07294df 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": "2ab4371edba33c23e8d680ed2bf6f98705b5cadb", "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 12859a199fab..b265bac8758e 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 60b77f200bef..cf4b592156e4 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,16 +33,15 @@ 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 @@ -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 b92eae6592dd..12b6f04cf294 100644 --- a/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_metadata.json +++ b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/_metadata.json @@ -5,13 +5,13 @@ "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,11 +91,10 @@ "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", 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 000000000000..74e48ecd07cf --- /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 27e399f3e310..592c5219c387 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, 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 @@ -48,62 +40,63 @@ 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.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 000000000000..138f663c53a4 --- /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 59deb8c7263b..e5754a47ce68 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 b1121365385a..8acb2c057e6d 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 ca01ad876a4d..821fe6bbf1b9 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,11 +37,11 @@ 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 @@ -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 000000000000..74e48ecd07cf --- /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 5ecd23ba3ad7..e9efdff4dda8 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, 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 @@ -41,65 +35,69 @@ class StorageCacheManagementClient(object): :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.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/_asc_operations_operations.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_asc_operations_operations.py index b92ff67d68ab..9fc1105af4e7 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/_caches_operations.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/aio/operations/_caches_operations.py index a766d890303c..7798f541f891 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 ae89eb191239..bc85dfb0c674 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 52504304edf9..31f0d09282ec 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 09cb276b9ba8..5919a76ea17a 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_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,5 @@ 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 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 69294603a06d..cd67d08304a2 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 f911ccab4660..1f3147c22440 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 c9d72405a55a..fc75c4f61a02 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,53 @@ # 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 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, 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 2b21dd305e28..000000000000 --- 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 3ddd000f39e3..1d889a41d134 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,18 +310,18 @@ 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 """ @@ -313,6 +372,29 @@ def __init__( directory_services_settings: Optional["CacheDirectorySettings"] = 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 + """ super(Cache, self).__init__(**kwargs) self.tags = tags self.id = None @@ -341,26 +423,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 +475,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 +511,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 +536,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 +552,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 +573,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 +591,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 +610,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 +627,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 +653,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 +675,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 +703,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 +724,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 +760,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 +783,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 +797,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 +808,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 +822,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 +833,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 +851,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 +906,8 @@ def __init__( self, **kwargs ): + """ + """ super(CacheUpgradeStatus, self).__init__(**kwargs) self.current_firmware_version = None self.firmware_update_status = None @@ -748,38 +921,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 +991,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 +1040,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 +1060,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 +1076,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 +1090,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 +1101,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 +1130,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 +1175,8 @@ def __init__( self, **kwargs ): + """ + """ super(Condition, self).__init__(**kwargs) self.timestamp = None self.message = None @@ -954,10 +1185,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 +1203,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 +1219,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 +1242,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 +1257,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 +1271,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 +1282,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 +1308,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 +1328,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 +1371,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 +1404,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 +1430,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 +1450,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 +1472,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 +1489,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 +1513,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 +1531,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 +1587,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 +1633,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 +1670,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 +1693,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 +1711,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 +1725,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 +1743,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 +1759,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,6 +1780,10 @@ 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 @@ -1445,11 +1800,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 +1824,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 +1874,8 @@ def __init__( self, **kwargs ): + """ + """ super(StorageTargetResource, self).__init__(**kwargs) self.name = None self.id = None @@ -1535,28 +1899,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 +1960,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 +1992,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 +2010,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 +2024,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 +2060,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 +2088,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 +2103,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 +2115,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 +2138,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 +2156,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 +2170,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 +2181,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 +2199,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 +2235,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 5ac4021707e2..da3ba535a618 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/_asc_operations_operations.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_asc_operations_operations.py index b8409f97c596..5a47df6f87e4 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 = "2021-09-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/_caches_operations.py b/sdk/storage/azure-mgmt-storagecache/azure/mgmt/storagecache/operations/_caches_operations.py index 82db0b3210c8..9ced64ff0fe2 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 = "2021-09-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 = "2021-09-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 = "2021-09-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 = "2021-09-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 = "2021-09-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 = "2021-09-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 = "2021-09-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 = "2021-09-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 = "2021-09-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 = "2021-09-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 = "2021-09-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 fc9b3e826608..a1ef9f2859d4 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 = "2021-09-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 32ec238ca5a2..0c4db69301f4 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 = "2021-09-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 f692a9f7a610..33de2eb93b81 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,137 @@ # 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 = "2021-09-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 = "2021-09-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 = "2021-09-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 + ) class StorageTargetOperations(object): """StorageTargetOperations operations. @@ -48,39 +161,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 +195,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 +217,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 +242,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 +261,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 +300,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 +320,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 +345,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 +364,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 +403,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 +423,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 +448,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 +467,5 @@ 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 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 54acd6315762..3050f02825e0 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 = "2021-09-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 = "2021-09-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 = "2021-09-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 = "2021-09-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 = "2021-09-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 f2665a0cf947..41057cca5c6b 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 = "2021-09-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 ) diff --git a/sdk/storage/azure-mgmt-storageimportexport/_meta.json b/sdk/storage/azure-mgmt-storageimportexport/_meta.json index d445615149a5..b04f97d8f1bf 100644 --- a/sdk/storage/azure-mgmt-storageimportexport/_meta.json +++ b/sdk/storage/azure-mgmt-storageimportexport/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.2", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.0", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "f802623b3e0ea71025e0c04d0478a0258aa3441d", + "commit": "2ab4371edba33c23e8d680ed2bf6f98705b5cadb", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/storageimportexport/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.0 --use=@autorest/modelerfour@4.19.2 --version=3.4.2", + "autorest_command": "autorest specification/storageimportexport/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/storageimportexport/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/__init__.py b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/__init__.py index 3573ec61388d..fe65f75b7076 100644 --- a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/__init__.py +++ b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['StorageImportExport'] -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-storageimportexport/azure/mgmt/storageimportexport/_configuration.py b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/_configuration.py index bc668f91b24f..71a1a08046d7 100644 --- a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/_configuration.py +++ b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/_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, Optional, 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, Optional - from azure.core.credentials import TokenCredential @@ -37,17 +35,16 @@ class StorageImportExportConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - accept_language=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + accept_language: Optional[str] = None, + **kwargs: Any + ) -> None: + super(StorageImportExportConfiguration, 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(StorageImportExportConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -72,4 +69,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-storageimportexport/azure/mgmt/storageimportexport/_metadata.json b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/_metadata.json index 42053ef5ac93..bf6e5b800d4f 100644 --- a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/_metadata.json +++ b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/_metadata.json @@ -5,13 +5,13 @@ "name": "StorageImportExport", "filename": "_storage_import_export", "description": "The Storage Import/Export Resource Provider API.", - "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": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageImportExportConfiguration\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageImportExportConfiguration\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageImportExportConfiguration\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageImportExportConfiguration\"]}}}" }, "global_parameters": { "sync": { @@ -66,7 +66,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 @@ -86,7 +86,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 @@ -103,11 +103,10 @@ "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\", \"Optional\"]}}, \"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\", \"Optional\"]}}, \"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\", \"Optional\"]}}, \"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\", \"Optional\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "locations": "LocationsOperations", diff --git a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/_patch.py b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/_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-storageimportexport/azure/mgmt/storageimportexport/_storage_import_export.py b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/_storage_import_export.py index d05fda135d1f..a987d588f01c 100644 --- a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/_storage_import_export.py +++ b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/_storage_import_export.py @@ -6,27 +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 StorageImportExportConfiguration +from .operations import BitLockerKeysOperations, JobsOperations, LocationsOperations, Operations + 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 StorageImportExportConfiguration -from .operations import LocationsOperations -from .operations import JobsOperations -from .operations import BitLockerKeysOperations -from .operations import Operations -from . import models - -class StorageImportExport(object): +class StorageImportExport: """The Storage Import/Export Resource Provider API. :ivar locations: LocationsOperations operations @@ -43,54 +38,56 @@ class StorageImportExport(object): :type subscription_id: str :param accept_language: Specifies the preferred language for the response. :type accept_language: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - accept_language=None, # type: Optional[str] - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = StorageImportExportConfiguration(credential, subscription_id, accept_language, **kwargs) + credential: "TokenCredential", + subscription_id: str, + accept_language: Optional[str] = None, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = StorageImportExportConfiguration(credential=credential, subscription_id=subscription_id, accept_language=accept_language, **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.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.bit_locker_keys = BitLockerKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.locations = LocationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.bit_locker_keys = BitLockerKeysOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - 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-storageimportexport/azure/mgmt/storageimportexport/_vendor.py b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/_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-storageimportexport/azure/mgmt/storageimportexport/aio/__init__.py b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/aio/__init__.py index 9dacfa50491b..48b69ede79cd 100644 --- a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/aio/__init__.py @@ -8,3 +8,8 @@ from ._storage_import_export import StorageImportExport __all__ = ['StorageImportExport'] + +# `._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-storageimportexport/azure/mgmt/storageimportexport/aio/_configuration.py b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/aio/_configuration.py index 6790d64ebbcc..88e9dc3cd48a 100644 --- a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/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 @@ -40,11 +40,11 @@ def __init__( accept_language: Optional[str] = None, **kwargs: Any ) -> None: + super(StorageImportExportConfiguration, 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(StorageImportExportConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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-storageimportexport/azure/mgmt/storageimportexport/aio/_patch.py b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/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-storageimportexport/azure/mgmt/storageimportexport/aio/_storage_import_export.py b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/aio/_storage_import_export.py index d896a7bdb757..02f697c4d332 100644 --- a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/aio/_storage_import_export.py +++ b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/aio/_storage_import_export.py @@ -6,25 +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 StorageImportExportConfiguration +from .operations import BitLockerKeysOperations, JobsOperations, LocationsOperations, Operations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import StorageImportExportConfiguration -from .operations import LocationsOperations -from .operations import JobsOperations -from .operations import BitLockerKeysOperations -from .operations import Operations -from .. import models - - -class StorageImportExport(object): +class StorageImportExport: """The Storage Import/Export Resource Provider API. :ivar locations: LocationsOperations operations @@ -41,7 +38,8 @@ class StorageImportExport(object): :type subscription_id: str :param accept_language: Specifies the preferred language for the response. :type accept_language: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( @@ -49,44 +47,47 @@ def __init__( credential: "AsyncTokenCredential", subscription_id: str, accept_language: Optional[str] = None, - 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 = StorageImportExportConfiguration(credential, subscription_id, accept_language, **kwargs) + self._config = StorageImportExportConfiguration(credential=credential, subscription_id=subscription_id, accept_language=accept_language, **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.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.bit_locker_keys = BitLockerKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.locations = LocationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.bit_locker_keys = BitLockerKeysOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - 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-storageimportexport/azure/mgmt/storageimportexport/aio/operations/_bit_locker_keys_operations.py b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/aio/operations/_bit_locker_keys_operations.py index 19a5fdbcd826..6dfd0ac24188 100644 --- a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/aio/operations/_bit_locker_keys_operations.py +++ b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/aio/operations/_bit_locker_keys_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._bit_locker_keys_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, job_name: str, @@ -55,8 +61,10 @@ def list( within the user subscription. :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 GetBitLockerKeysResponse or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~storage_import_export.models.GetBitLockerKeysResponse] + :return: An iterator like instance of either GetBitLockerKeysResponse or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~storage_import_export.models.GetBitLockerKeysResponse] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GetBitLockerKeysResponse"] @@ -64,38 +72,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if self._config.accept_language is not None: - header_parameters['Accept-Language'] = self._serialize.header("self._config.accept_language", self._config.accept_language, 'str') - 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 = { - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_request( + job_name=job_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + accept_language=self._config.accept_language, + 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( + job_name=job_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + accept_language=self._config.accept_language, + 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('GetBitLockerKeysResponse', pipeline_response) + deserialized = self._deserialize("GetBitLockerKeysResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,12 +113,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/aio/operations/_jobs_operations.py b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/aio/operations/_jobs_operations.py index 48cfa7354898..c46b3ba81b35 100644 --- a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/aio/operations/_jobs_operations.py +++ b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/aio/operations/_jobs_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, 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.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._jobs_operations import build_create_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_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_by_subscription( self, top: Optional[int] = None, @@ -64,40 +70,35 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if self._config.accept_language is not None: - header_parameters['Accept-Language'] = self._serialize.header("self._config.accept_language", self._config.accept_language, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'long') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - 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_subscription_request( + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + accept_language=self._config.accept_language, + template_url=self.list_by_subscription.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_subscription_request( + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + accept_language=self._config.accept_language, + 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('ListJobsResponse', pipeline_response) + deserialized = self._deserialize("ListJobsResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,17 +111,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ImportExport/jobs'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -148,41 +151,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if self._config.accept_language is not None: - header_parameters['Accept-Language'] = self._serialize.header("self._config.accept_language", self._config.accept_language, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'long') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - 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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + top=top, + filter=filter, + accept_language=self._config.accept_language, + 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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + top=top, + filter=filter, + accept_language=self._config.accept_language, + 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('ListJobsResponse', pipeline_response) + deserialized = self._deserialize("ListJobsResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -195,17 +194,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ImportExport/jobs'} # type: ignore + @distributed_trace_async async def get( self, job_name: str, @@ -229,35 +230,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if self._config.accept_language is not None: - header_parameters['Accept-Language'] = self._serialize.header("self._config.accept_language", self._config.accept_language, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + job_name=job_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + accept_language=self._config.accept_language, + 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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -266,8 +256,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ImportExport/jobs/{jobName}'} # type: ignore + + @distributed_trace_async async def update( self, job_name: str, @@ -296,40 +289,29 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if self._config.accept_language is not None: - header_parameters['Accept-Language'] = self._serialize.header("self._config.accept_language", self._config.accept_language, 'str') - 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] - body_content = self._serialize.body(body, 'UpdateJobParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'UpdateJobParameters') + + request = build_update_request( + job_name=job_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + accept_language=self._config.accept_language, + 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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -338,8 +320,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ImportExport/jobs/{jobName}'} # type: ignore + + @distributed_trace_async async def create( self, job_name: str, @@ -369,42 +354,30 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if self._config.accept_language is not None: - header_parameters['Accept-Language'] = self._serialize.header("self._config.accept_language", self._config.accept_language, 'str') - if client_tenant_id is not None: - header_parameters['x-ms-client-tenant-id'] = self._serialize.header("client_tenant_id", client_tenant_id, 'str') - 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] - body_content = self._serialize.body(body, 'PutJobParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'PutJobParameters') + + request = build_create_request( + job_name=job_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + accept_language=self._config.accept_language, + client_tenant_id=client_tenant_id, + template_url=self.create.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, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -417,8 +390,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ImportExport/jobs/{jobName}'} # type: ignore + + @distributed_trace_async async def delete( self, job_name: str, @@ -442,38 +418,28 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if self._config.accept_language is not None: - header_parameters['Accept-Language'] = self._serialize.header("self._config.accept_language", self._config.accept_language, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + job_name=job_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + accept_language=self._config.accept_language, + template_url=self.delete.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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ImportExport/jobs/{jobName}'} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/aio/operations/_locations_operations.py b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/aio/operations/_locations_operations.py index 8ed3f9813cea..259d810e62ca 100644 --- a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/aio/operations/_locations_operations.py +++ b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/aio/operations/_locations_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._locations_operations import build_get_request, 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 @@ -50,7 +56,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 LocationsResponse or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~storage_import_export.models.LocationsResponse] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~storage_import_export.models.LocationsResponse] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationsResponse"] @@ -58,32 +65,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if self._config.accept_language is not None: - header_parameters['Accept-Language'] = self._serialize.header("self._config.accept_language", self._config.accept_language, 'str') - 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( + accept_language=self._config.accept_language, + 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( + accept_language=self._config.accept_language, + 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('LocationsResponse', pipeline_response) + deserialized = self._deserialize("LocationsResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -96,17 +100,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/providers/Microsoft.ImportExport/locations'} # type: ignore + @distributed_trace_async async def get( self, location_name: str, @@ -127,33 +133,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if self._config.accept_language is not None: - header_parameters['Accept-Language'] = self._serialize.header("self._config.accept_language", self._config.accept_language, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + location_name=location_name, + accept_language=self._config.accept_language, + 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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Location', pipeline_response) @@ -162,4 +157,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.ImportExport/locations/{locationName}'} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/aio/operations/_operations.py index d5fd8a8c7c8a..b56debdf1f7e 100644 --- a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/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( """Returns the list of operations supported by the import/export resource provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListOperationsResponse or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~storage_import_export.models.ListOperationsResponse] + :return: An iterator like instance of either ListOperationsResponse or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~storage_import_export.models.ListOperationsResponse] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ListOperationsResponse"] @@ -57,32 +65,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if self._config.accept_language is not None: - header_parameters['Accept-Language'] = self._serialize.header("self._config.accept_language", self._config.accept_language, 'str') - 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( + accept_language=self._config.accept_language, + 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( + accept_language=self._config.accept_language, + 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('ListOperationsResponse', pipeline_response) + deserialized = self._deserialize("ListOperationsResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -95,12 +100,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/models/__init__.py b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/models/__init__.py index fc9e97de94a4..2f63a52674c5 100644 --- a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/models/__init__.py +++ b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/models/__init__.py @@ -6,54 +6,30 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import DeliveryPackageInformation - from ._models_py3 import DriveBitLockerKey - from ._models_py3 import DriveStatus - from ._models_py3 import EncryptionKeyDetails - from ._models_py3 import ErrorResponse - from ._models_py3 import ErrorResponseErrorDetailsItem - from ._models_py3 import Export - from ._models_py3 import GetBitLockerKeysResponse - from ._models_py3 import IdentityDetails - from ._models_py3 import JobDetails - from ._models_py3 import JobResponse - from ._models_py3 import ListJobsResponse - from ._models_py3 import ListOperationsResponse - from ._models_py3 import Location - from ._models_py3 import LocationsResponse - from ._models_py3 import Operation - from ._models_py3 import PackageInformation - from ._models_py3 import PutJobParameters - from ._models_py3 import ReturnAddress - from ._models_py3 import ReturnShipping - from ._models_py3 import ShippingInformation - from ._models_py3 import SystemData - from ._models_py3 import UpdateJobParameters -except (SyntaxError, ImportError): - from ._models import DeliveryPackageInformation # type: ignore - from ._models import DriveBitLockerKey # type: ignore - from ._models import DriveStatus # type: ignore - from ._models import EncryptionKeyDetails # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ErrorResponseErrorDetailsItem # type: ignore - from ._models import Export # type: ignore - from ._models import GetBitLockerKeysResponse # type: ignore - from ._models import IdentityDetails # type: ignore - from ._models import JobDetails # type: ignore - from ._models import JobResponse # type: ignore - from ._models import ListJobsResponse # type: ignore - from ._models import ListOperationsResponse # type: ignore - from ._models import Location # type: ignore - from ._models import LocationsResponse # type: ignore - from ._models import Operation # type: ignore - from ._models import PackageInformation # type: ignore - from ._models import PutJobParameters # type: ignore - from ._models import ReturnAddress # type: ignore - from ._models import ReturnShipping # type: ignore - from ._models import ShippingInformation # type: ignore - from ._models import SystemData # type: ignore - from ._models import UpdateJobParameters # type: ignore +from ._models_py3 import DeliveryPackageInformation +from ._models_py3 import DriveBitLockerKey +from ._models_py3 import DriveStatus +from ._models_py3 import EncryptionKeyDetails +from ._models_py3 import ErrorResponse +from ._models_py3 import ErrorResponseErrorDetailsItem +from ._models_py3 import Export +from ._models_py3 import GetBitLockerKeysResponse +from ._models_py3 import IdentityDetails +from ._models_py3 import JobDetails +from ._models_py3 import JobResponse +from ._models_py3 import ListJobsResponse +from ._models_py3 import ListOperationsResponse +from ._models_py3 import Location +from ._models_py3 import LocationsResponse +from ._models_py3 import Operation +from ._models_py3 import PackageInformation +from ._models_py3 import PutJobParameters +from ._models_py3 import ReturnAddress +from ._models_py3 import ReturnShipping +from ._models_py3 import ShippingInformation +from ._models_py3 import SystemData +from ._models_py3 import UpdateJobParameters + from ._storage_import_export_enums import ( CreatedByType, diff --git a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/models/_models.py b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/models/_models.py deleted file mode 100644 index 85835b038804..000000000000 --- a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/models/_models.py +++ /dev/null @@ -1,970 +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. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class DeliveryPackageInformation(msrest.serialization.Model): - """Contains information about the delivery package being shipped by the customer to the Microsoft data center. - - All required parameters must be populated in order to send to Azure. - - :param carrier_name: Required. The name of the carrier that is used to ship the import or - export drives. - :type carrier_name: str - :param tracking_number: Required. The tracking number of the package. - :type tracking_number: str - :param drive_count: The number of drives included in the package. - :type drive_count: long - :param ship_date: The date when the package is shipped. - :type ship_date: str - """ - - _validation = { - 'carrier_name': {'required': True}, - 'tracking_number': {'required': True}, - } - - _attribute_map = { - 'carrier_name': {'key': 'carrierName', 'type': 'str'}, - 'tracking_number': {'key': 'trackingNumber', 'type': 'str'}, - 'drive_count': {'key': 'driveCount', 'type': 'long'}, - 'ship_date': {'key': 'shipDate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DeliveryPackageInformation, self).__init__(**kwargs) - self.carrier_name = kwargs['carrier_name'] - self.tracking_number = kwargs['tracking_number'] - self.drive_count = kwargs.get('drive_count', None) - self.ship_date = kwargs.get('ship_date', None) - - -class DriveBitLockerKey(msrest.serialization.Model): - """BitLocker recovery key or password to the specified drive. - - :param bit_locker_key: BitLocker recovery key or password. - :type bit_locker_key: str - :param drive_id: Drive ID. - :type drive_id: str - """ - - _attribute_map = { - 'bit_locker_key': {'key': 'bitLockerKey', 'type': 'str'}, - 'drive_id': {'key': 'driveId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DriveBitLockerKey, self).__init__(**kwargs) - self.bit_locker_key = kwargs.get('bit_locker_key', None) - self.drive_id = kwargs.get('drive_id', None) - - -class DriveStatus(msrest.serialization.Model): - """Provides information about the drive's status. - - :param drive_id: The drive's hardware serial number, without spaces. - :type drive_id: str - :param bit_locker_key: The BitLocker key used to encrypt the drive. - :type bit_locker_key: str - :param manifest_file: The relative path of the manifest file on the drive. - :type manifest_file: str - :param manifest_hash: The Base16-encoded MD5 hash of the manifest file on the drive. - :type manifest_hash: str - :param drive_header_hash: The drive header hash value. - :type drive_header_hash: str - :param state: The drive's current state. Possible values include: "Specified", "Received", - "NeverReceived", "Transferring", "Completed", "CompletedMoreInfo", "ShippedBack". - :type state: str or ~storage_import_export.models.DriveState - :param copy_status: Detailed status about the data transfer process. This field is not returned - in the response until the drive is in the Transferring state. - :type copy_status: str - :param percent_complete: Percentage completed for the drive. - :type percent_complete: long - :param verbose_log_uri: A URI that points to the blob containing the verbose log for the data - transfer operation. - :type verbose_log_uri: str - :param error_log_uri: A URI that points to the blob containing the error log for the data - transfer operation. - :type error_log_uri: str - :param manifest_uri: A URI that points to the blob containing the drive manifest file. - :type manifest_uri: str - :param bytes_succeeded: Bytes successfully transferred for the drive. - :type bytes_succeeded: long - """ - - _attribute_map = { - 'drive_id': {'key': 'driveId', 'type': 'str'}, - 'bit_locker_key': {'key': 'bitLockerKey', 'type': 'str'}, - 'manifest_file': {'key': 'manifestFile', 'type': 'str'}, - 'manifest_hash': {'key': 'manifestHash', 'type': 'str'}, - 'drive_header_hash': {'key': 'driveHeaderHash', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'copy_status': {'key': 'copyStatus', 'type': 'str'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'long'}, - 'verbose_log_uri': {'key': 'verboseLogUri', 'type': 'str'}, - 'error_log_uri': {'key': 'errorLogUri', 'type': 'str'}, - 'manifest_uri': {'key': 'manifestUri', 'type': 'str'}, - 'bytes_succeeded': {'key': 'bytesSucceeded', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(DriveStatus, self).__init__(**kwargs) - self.drive_id = kwargs.get('drive_id', None) - self.bit_locker_key = kwargs.get('bit_locker_key', None) - self.manifest_file = kwargs.get('manifest_file', None) - self.manifest_hash = kwargs.get('manifest_hash', None) - self.drive_header_hash = kwargs.get('drive_header_hash', None) - self.state = kwargs.get('state', None) - self.copy_status = kwargs.get('copy_status', None) - self.percent_complete = kwargs.get('percent_complete', None) - self.verbose_log_uri = kwargs.get('verbose_log_uri', None) - self.error_log_uri = kwargs.get('error_log_uri', None) - self.manifest_uri = kwargs.get('manifest_uri', None) - self.bytes_succeeded = kwargs.get('bytes_succeeded', None) - - -class EncryptionKeyDetails(msrest.serialization.Model): - """Specifies the encryption key properties. - - :param kek_type: The type of kek encryption key. Possible values include: "MicrosoftManaged", - "CustomerManaged". Default value: "MicrosoftManaged". - :type kek_type: str or ~storage_import_export.models.EncryptionKekType - :param kek_url: Specifies the url for kek encryption key. - :type kek_url: str - :param kek_vault_resource_id: Specifies the keyvault resource id for kek encryption key. - :type kek_vault_resource_id: str - """ - - _attribute_map = { - 'kek_type': {'key': 'kekType', 'type': 'str'}, - 'kek_url': {'key': 'kekUrl', 'type': 'str'}, - 'kek_vault_resource_id': {'key': 'kekVaultResourceID', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EncryptionKeyDetails, self).__init__(**kwargs) - self.kek_type = kwargs.get('kek_type', "MicrosoftManaged") - self.kek_url = kwargs.get('kek_url', None) - self.kek_vault_resource_id = kwargs.get('kek_vault_resource_id', None) - - -class ErrorResponse(msrest.serialization.Model): - """Response when errors occurred. - - :param code: Provides information about the error code. - :type code: str - :param message: Provides information about the error message. - :type message: str - :param target: Provides information about the error target. - :type target: str - :param details: Describes the error details if present. - :type details: list[~storage_import_export.models.ErrorResponseErrorDetailsItem] - :param innererror: Inner error object if present. - :type innererror: any - """ - - _attribute_map = { - 'code': {'key': 'error.code', 'type': 'str'}, - 'message': {'key': 'error.message', 'type': 'str'}, - 'target': {'key': 'error.target', 'type': 'str'}, - 'details': {'key': 'error.details', 'type': '[ErrorResponseErrorDetailsItem]'}, - 'innererror': {'key': 'error.innererror', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.target = kwargs.get('target', None) - self.details = kwargs.get('details', None) - self.innererror = kwargs.get('innererror', None) - - -class ErrorResponseErrorDetailsItem(msrest.serialization.Model): - """ErrorResponseErrorDetailsItem. - - :param code: Provides information about the error code. - :type code: str - :param target: Provides information about the error target. - :type target: str - :param message: Provides information about the error message. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponseErrorDetailsItem, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.target = kwargs.get('target', None) - self.message = kwargs.get('message', None) - - -class Export(msrest.serialization.Model): - """A property containing information about the blobs to be exported for an export job. This property is required for export jobs, but must not be specified for import jobs. - - :param blob_list_blob_path: The relative URI to the block blob that contains the list of blob - paths or blob path prefixes as defined above, beginning with the container name. If the blob is - in root container, the URI must begin with $root. - :type blob_list_blob_path: str - :param blob_path: A collection of blob-path strings. - :type blob_path: list[str] - :param blob_path_prefix: A collection of blob-prefix strings. - :type blob_path_prefix: list[str] - """ - - _attribute_map = { - 'blob_list_blob_path': {'key': 'blobListBlobPath', 'type': 'str'}, - 'blob_path': {'key': 'blobList.blobPath', 'type': '[str]'}, - 'blob_path_prefix': {'key': 'blobList.blobPathPrefix', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(Export, self).__init__(**kwargs) - self.blob_list_blob_path = kwargs.get('blob_list_blob_path', None) - self.blob_path = kwargs.get('blob_path', None) - self.blob_path_prefix = kwargs.get('blob_path_prefix', None) - - -class GetBitLockerKeysResponse(msrest.serialization.Model): - """GetBitLockerKeys response. - - :param value: drive status. - :type value: list[~storage_import_export.models.DriveBitLockerKey] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DriveBitLockerKey]'}, - } - - def __init__( - self, - **kwargs - ): - super(GetBitLockerKeysResponse, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class IdentityDetails(msrest.serialization.Model): - """Specifies the identity properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param type: The type of identity. Possible values include: "None", "SystemAssigned", - "UserAssigned". Default value: "None". - :type type: str or ~storage_import_export.models.IdentityType - :ivar principal_id: Specifies the principal id for the identity for the job. - :vartype principal_id: str - :ivar tenant_id: Specifies the tenant id for the identity for the job. - :vartype tenant_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IdentityDetails, self).__init__(**kwargs) - self.type = kwargs.get('type', "None") - self.principal_id = None - self.tenant_id = None - - -class JobDetails(msrest.serialization.Model): - """Specifies the job properties. - - :param storage_account_id: The resource identifier of the storage account where data will be - imported to or exported from. - :type storage_account_id: str - :param job_type: The type of job. - :type job_type: str - :param return_address: Specifies the return address information for the job. - :type return_address: ~storage_import_export.models.ReturnAddress - :param return_shipping: Specifies the return carrier and customer's account with the carrier. - :type return_shipping: ~storage_import_export.models.ReturnShipping - :param shipping_information: Contains information about the Microsoft datacenter to which the - drives should be shipped. - :type shipping_information: ~storage_import_export.models.ShippingInformation - :param delivery_package: Contains information about the package being shipped by the customer - to the Microsoft data center. - :type delivery_package: ~storage_import_export.models.DeliveryPackageInformation - :param return_package: Contains information about the package being shipped from the Microsoft - data center to the customer to return the drives. The format is the same as the deliveryPackage - property above. This property is not included if the drives have not yet been returned. - :type return_package: ~storage_import_export.models.PackageInformation - :param diagnostics_path: The virtual blob directory to which the copy logs and backups of drive - manifest files (if enabled) will be stored. - :type diagnostics_path: str - :param log_level: Default value is Error. Indicates whether error logging or verbose logging - will be enabled. - :type log_level: str - :param backup_drive_manifest: Default value is false. Indicates whether the manifest files on - the drives should be copied to block blobs. - :type backup_drive_manifest: bool - :param state: Current state of the job. - :type state: str - :param cancel_requested: Indicates whether a request has been submitted to cancel the job. - :type cancel_requested: bool - :param percent_complete: Overall percentage completed for the job. - :type percent_complete: long - :param incomplete_blob_list_uri: A blob path that points to a block blob containing a list of - blob names that were not exported due to insufficient drive space. If all blobs were exported - successfully, then this element is not included in the response. - :type incomplete_blob_list_uri: str - :param drive_list: List of up to ten drives that comprise the job. The drive list is a required - element for an import job; it is not specified for export jobs. - :type drive_list: list[~storage_import_export.models.DriveStatus] - :param export: A property containing information about the blobs to be exported for an export - job. This property is included for export jobs only. - :type export: ~storage_import_export.models.Export - :param provisioning_state: Specifies the provisioning state of the job. - :type provisioning_state: str - :param encryption_key: Contains information about the encryption key. - :type encryption_key: ~storage_import_export.models.EncryptionKeyDetails - """ - - _attribute_map = { - 'storage_account_id': {'key': 'storageAccountId', 'type': 'str'}, - 'job_type': {'key': 'jobType', 'type': 'str'}, - 'return_address': {'key': 'returnAddress', 'type': 'ReturnAddress'}, - 'return_shipping': {'key': 'returnShipping', 'type': 'ReturnShipping'}, - 'shipping_information': {'key': 'shippingInformation', 'type': 'ShippingInformation'}, - 'delivery_package': {'key': 'deliveryPackage', 'type': 'DeliveryPackageInformation'}, - 'return_package': {'key': 'returnPackage', 'type': 'PackageInformation'}, - 'diagnostics_path': {'key': 'diagnosticsPath', 'type': 'str'}, - 'log_level': {'key': 'logLevel', 'type': 'str'}, - 'backup_drive_manifest': {'key': 'backupDriveManifest', 'type': 'bool'}, - 'state': {'key': 'state', 'type': 'str'}, - 'cancel_requested': {'key': 'cancelRequested', 'type': 'bool'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'long'}, - 'incomplete_blob_list_uri': {'key': 'incompleteBlobListUri', 'type': 'str'}, - 'drive_list': {'key': 'driveList', 'type': '[DriveStatus]'}, - 'export': {'key': 'export', 'type': 'Export'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'encryption_key': {'key': 'encryptionKey', 'type': 'EncryptionKeyDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(JobDetails, self).__init__(**kwargs) - self.storage_account_id = kwargs.get('storage_account_id', None) - self.job_type = kwargs.get('job_type', None) - self.return_address = kwargs.get('return_address', None) - self.return_shipping = kwargs.get('return_shipping', None) - self.shipping_information = kwargs.get('shipping_information', None) - self.delivery_package = kwargs.get('delivery_package', None) - self.return_package = kwargs.get('return_package', None) - self.diagnostics_path = kwargs.get('diagnostics_path', None) - self.log_level = kwargs.get('log_level', None) - self.backup_drive_manifest = kwargs.get('backup_drive_manifest', None) - self.state = kwargs.get('state', None) - self.cancel_requested = kwargs.get('cancel_requested', None) - self.percent_complete = kwargs.get('percent_complete', None) - self.incomplete_blob_list_uri = kwargs.get('incomplete_blob_list_uri', None) - self.drive_list = kwargs.get('drive_list', None) - self.export = kwargs.get('export', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.encryption_key = kwargs.get('encryption_key', None) - - -class JobResponse(msrest.serialization.Model): - """Contains the job information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar system_data: SystemData of ImportExport Jobs. - :vartype system_data: ~storage_import_export.models.SystemData - :ivar id: Specifies the resource identifier of the job. - :vartype id: str - :ivar name: Specifies the name of the job. - :vartype name: str - :ivar type: Specifies the type of the job resource. - :vartype type: str - :param location: Specifies the Azure location where the job is created. - :type location: str - :param tags: A set of tags. Specifies the tags that are assigned to the job. - :type tags: any - :param properties: Specifies the job properties. - :type properties: ~storage_import_export.models.JobDetails - :param identity: Specifies the job identity details. - :type identity: ~storage_import_export.models.IdentityDetails - """ - - _validation = { - 'system_data': {'readonly': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': 'object'}, - 'properties': {'key': 'properties', 'type': 'JobDetails'}, - 'identity': {'key': 'identity', 'type': 'IdentityDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(JobResponse, self).__init__(**kwargs) - self.system_data = None - self.id = None - self.name = None - self.type = None - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.properties = kwargs.get('properties', None) - self.identity = kwargs.get('identity', None) - - -class ListJobsResponse(msrest.serialization.Model): - """List jobs response. - - :param next_link: link to next batch of jobs. - :type next_link: str - :param value: Job list. - :type value: list[~storage_import_export.models.JobResponse] - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[JobResponse]'}, - } - - def __init__( - self, - **kwargs - ): - super(ListJobsResponse, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs.get('value', None) - - -class ListOperationsResponse(msrest.serialization.Model): - """List operations response. - - :param value: operations. - :type value: list[~storage_import_export.models.Operation] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - } - - def __init__( - self, - **kwargs - ): - super(ListOperationsResponse, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class Location(msrest.serialization.Model): - """Provides information about an Azure data center location. - - :param id: Specifies the resource identifier of the location. - :type id: str - :param name: Specifies the name of the location. Use List Locations to get all supported - locations. - :type name: str - :param type: Specifies the type of the location. - :type type: str - :param recipient_name: The recipient name to use when shipping the drives to the Azure data - center. - :type recipient_name: str - :param street_address1: The first line of the street address to use when shipping the drives to - the Azure data center. - :type street_address1: str - :param street_address2: The second line of the street address to use when shipping the drives - to the Azure data center. - :type street_address2: str - :param city: The city name to use when shipping the drives to the Azure data center. - :type city: str - :param state_or_province: The state or province to use when shipping the drives to the Azure - data center. - :type state_or_province: str - :param postal_code: The postal code to use when shipping the drives to the Azure data center. - :type postal_code: str - :param country_or_region: The country or region to use when shipping the drives to the Azure - data center. - :type country_or_region: str - :param phone: The phone number for the Azure data center. - :type phone: str - :param additional_shipping_information: Additional shipping information for customer, specific - to datacenter to which customer should send their disks. - :type additional_shipping_information: str - :param supported_carriers: A list of carriers that are supported at this location. - :type supported_carriers: list[str] - :param alternate_locations: A list of location IDs that should be used to ship shipping drives - to for jobs created against the current location. If the current location is active, it will be - part of the list. If it is temporarily closed due to maintenance, this list may contain other - locations. - :type alternate_locations: list[str] - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'recipient_name': {'key': 'properties.recipientName', 'type': 'str'}, - 'street_address1': {'key': 'properties.streetAddress1', 'type': 'str'}, - 'street_address2': {'key': 'properties.streetAddress2', 'type': 'str'}, - 'city': {'key': 'properties.city', 'type': 'str'}, - 'state_or_province': {'key': 'properties.stateOrProvince', 'type': 'str'}, - 'postal_code': {'key': 'properties.postalCode', 'type': 'str'}, - 'country_or_region': {'key': 'properties.countryOrRegion', 'type': 'str'}, - 'phone': {'key': 'properties.phone', 'type': 'str'}, - 'additional_shipping_information': {'key': 'properties.additionalShippingInformation', 'type': 'str'}, - 'supported_carriers': {'key': 'properties.supportedCarriers', 'type': '[str]'}, - 'alternate_locations': {'key': 'properties.alternateLocations', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(Location, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - self.recipient_name = kwargs.get('recipient_name', None) - self.street_address1 = kwargs.get('street_address1', None) - self.street_address2 = kwargs.get('street_address2', None) - self.city = kwargs.get('city', None) - self.state_or_province = kwargs.get('state_or_province', None) - self.postal_code = kwargs.get('postal_code', None) - self.country_or_region = kwargs.get('country_or_region', None) - self.phone = kwargs.get('phone', None) - self.additional_shipping_information = kwargs.get('additional_shipping_information', None) - self.supported_carriers = kwargs.get('supported_carriers', None) - self.alternate_locations = kwargs.get('alternate_locations', None) - - -class LocationsResponse(msrest.serialization.Model): - """Locations response. - - :param value: locations. - :type value: list[~storage_import_export.models.Location] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Location]'}, - } - - def __init__( - self, - **kwargs - ): - super(LocationsResponse, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class Operation(msrest.serialization.Model): - """Describes a supported operation by the Storage Import/Export job API. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Name of the operation. - :type name: str - :param provider: The resource provider name to which the operation belongs. - :type provider: str - :param resource: The name of the resource to which the operation belongs. - :type resource: str - :param operation: The display name of the operation. - :type operation: str - :param description: Short description of the operation. - :type description: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'provider': {'key': 'display.provider', 'type': 'str'}, - 'resource': {'key': 'display.resource', 'type': 'str'}, - 'operation': {'key': 'display.operation', 'type': 'str'}, - 'description': {'key': 'display.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs['name'] - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class PackageInformation(msrest.serialization.Model): - """Contains information about the package being shipped by the customer to the Microsoft data center. - - All required parameters must be populated in order to send to Azure. - - :param carrier_name: Required. The name of the carrier that is used to ship the import or - export drives. - :type carrier_name: str - :param tracking_number: Required. The tracking number of the package. - :type tracking_number: str - :param drive_count: Required. The number of drives included in the package. - :type drive_count: long - :param ship_date: Required. The date when the package is shipped. - :type ship_date: str - """ - - _validation = { - 'carrier_name': {'required': True}, - 'tracking_number': {'required': True}, - 'drive_count': {'required': True}, - 'ship_date': {'required': True}, - } - - _attribute_map = { - 'carrier_name': {'key': 'carrierName', 'type': 'str'}, - 'tracking_number': {'key': 'trackingNumber', 'type': 'str'}, - 'drive_count': {'key': 'driveCount', 'type': 'long'}, - 'ship_date': {'key': 'shipDate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PackageInformation, self).__init__(**kwargs) - self.carrier_name = kwargs['carrier_name'] - self.tracking_number = kwargs['tracking_number'] - self.drive_count = kwargs['drive_count'] - self.ship_date = kwargs['ship_date'] - - -class PutJobParameters(msrest.serialization.Model): - """Put Job parameters. - - :param location: Specifies the supported Azure location where the job should be created. - :type location: str - :param tags: A set of tags. Specifies the tags that will be assigned to the job. - :type tags: any - :param properties: Specifies the job properties. - :type properties: ~storage_import_export.models.JobDetails - """ - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': 'object'}, - 'properties': {'key': 'properties', 'type': 'JobDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(PutJobParameters, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.properties = kwargs.get('properties', None) - - -class ReturnAddress(msrest.serialization.Model): - """Specifies the return address information for the job. - - All required parameters must be populated in order to send to Azure. - - :param recipient_name: Required. The name of the recipient who will receive the hard drives - when they are returned. - :type recipient_name: str - :param street_address1: Required. The first line of the street address to use when returning - the drives. - :type street_address1: str - :param street_address2: The second line of the street address to use when returning the drives. - :type street_address2: str - :param city: Required. The city name to use when returning the drives. - :type city: str - :param state_or_province: The state or province to use when returning the drives. - :type state_or_province: str - :param postal_code: Required. The postal code to use when returning the drives. - :type postal_code: str - :param country_or_region: Required. The country or region to use when returning the drives. - :type country_or_region: str - :param phone: Required. Phone number of the recipient of the returned drives. - :type phone: str - :param email: Required. Email address of the recipient of the returned drives. - :type email: str - """ - - _validation = { - 'recipient_name': {'required': True}, - 'street_address1': {'required': True}, - 'city': {'required': True}, - 'postal_code': {'required': True}, - 'country_or_region': {'required': True}, - 'phone': {'required': True}, - 'email': {'required': True}, - } - - _attribute_map = { - 'recipient_name': {'key': 'recipientName', 'type': 'str'}, - 'street_address1': {'key': 'streetAddress1', 'type': 'str'}, - 'street_address2': {'key': 'streetAddress2', 'type': 'str'}, - 'city': {'key': 'city', 'type': 'str'}, - 'state_or_province': {'key': 'stateOrProvince', 'type': 'str'}, - 'postal_code': {'key': 'postalCode', 'type': 'str'}, - 'country_or_region': {'key': 'countryOrRegion', 'type': 'str'}, - 'phone': {'key': 'phone', 'type': 'str'}, - 'email': {'key': 'email', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ReturnAddress, self).__init__(**kwargs) - self.recipient_name = kwargs['recipient_name'] - self.street_address1 = kwargs['street_address1'] - self.street_address2 = kwargs.get('street_address2', None) - self.city = kwargs['city'] - self.state_or_province = kwargs.get('state_or_province', None) - self.postal_code = kwargs['postal_code'] - self.country_or_region = kwargs['country_or_region'] - self.phone = kwargs['phone'] - self.email = kwargs['email'] - - -class ReturnShipping(msrest.serialization.Model): - """Specifies the return carrier and customer's account with the carrier. - - All required parameters must be populated in order to send to Azure. - - :param carrier_name: Required. The carrier's name. - :type carrier_name: str - :param carrier_account_number: Required. The customer's account number with the carrier. - :type carrier_account_number: str - """ - - _validation = { - 'carrier_name': {'required': True}, - 'carrier_account_number': {'required': True}, - } - - _attribute_map = { - 'carrier_name': {'key': 'carrierName', 'type': 'str'}, - 'carrier_account_number': {'key': 'carrierAccountNumber', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ReturnShipping, self).__init__(**kwargs) - self.carrier_name = kwargs['carrier_name'] - self.carrier_account_number = kwargs['carrier_account_number'] - - -class ShippingInformation(msrest.serialization.Model): - """Contains information about the Microsoft datacenter to which the drives should be shipped. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param recipient_name: The name of the recipient who will receive the hard drives when they are - returned. - :type recipient_name: str - :param street_address1: The first line of the street address to use when returning the drives. - :type street_address1: str - :param street_address2: The second line of the street address to use when returning the drives. - :type street_address2: str - :param city: The city name to use when returning the drives. - :type city: str - :param state_or_province: The state or province to use when returning the drives. - :type state_or_province: str - :param postal_code: The postal code to use when returning the drives. - :type postal_code: str - :param country_or_region: The country or region to use when returning the drives. - :type country_or_region: str - :param phone: Phone number of the recipient of the returned drives. - :type phone: str - :ivar additional_information: Additional shipping information for customer, specific to - datacenter to which customer should send their disks. - :vartype additional_information: str - """ - - _validation = { - 'additional_information': {'readonly': True}, - } - - _attribute_map = { - 'recipient_name': {'key': 'recipientName', 'type': 'str'}, - 'street_address1': {'key': 'streetAddress1', 'type': 'str'}, - 'street_address2': {'key': 'streetAddress2', 'type': 'str'}, - 'city': {'key': 'city', 'type': 'str'}, - 'state_or_province': {'key': 'stateOrProvince', 'type': 'str'}, - 'postal_code': {'key': 'postalCode', 'type': 'str'}, - 'country_or_region': {'key': 'countryOrRegion', 'type': 'str'}, - 'phone': {'key': 'phone', 'type': 'str'}, - 'additional_information': {'key': 'additionalInformation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ShippingInformation, self).__init__(**kwargs) - self.recipient_name = kwargs.get('recipient_name', None) - self.street_address1 = kwargs.get('street_address1', None) - self.street_address2 = kwargs.get('street_address2', None) - self.city = kwargs.get('city', None) - self.state_or_province = kwargs.get('state_or_province', None) - self.postal_code = kwargs.get('postal_code', None) - self.country_or_region = kwargs.get('country_or_region', None) - self.phone = kwargs.get('phone', None) - self.additional_information = 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_import_export.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_import_export.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 UpdateJobParameters(msrest.serialization.Model): - """Update Job parameters. - - :param tags: A set of tags. Specifies the tags that will be assigned to the job. - :type tags: any - :param cancel_requested: If specified, the value must be true. The service will attempt to - cancel the job. - :type cancel_requested: bool - :param state: If specified, the value must be Shipping, which tells the Import/Export service - that the package for the job has been shipped. The ReturnAddress and DeliveryPackage properties - must have been set either in this request or in a previous request, otherwise the request will - fail. - :type state: str - :param return_address: Specifies the return address information for the job. - :type return_address: ~storage_import_export.models.ReturnAddress - :param return_shipping: Specifies the return carrier and customer's account with the carrier. - :type return_shipping: ~storage_import_export.models.ReturnShipping - :param delivery_package: Contains information about the package being shipped by the customer - to the Microsoft data center. - :type delivery_package: ~storage_import_export.models.DeliveryPackageInformation - :param log_level: Indicates whether error logging or verbose logging is enabled. - :type log_level: str - :param backup_drive_manifest: Indicates whether the manifest files on the drives should be - copied to block blobs. - :type backup_drive_manifest: bool - :param drive_list: List of drives that comprise the job. - :type drive_list: list[~storage_import_export.models.DriveStatus] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': 'object'}, - 'cancel_requested': {'key': 'properties.cancelRequested', 'type': 'bool'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'return_address': {'key': 'properties.returnAddress', 'type': 'ReturnAddress'}, - 'return_shipping': {'key': 'properties.returnShipping', 'type': 'ReturnShipping'}, - 'delivery_package': {'key': 'properties.deliveryPackage', 'type': 'DeliveryPackageInformation'}, - 'log_level': {'key': 'properties.logLevel', 'type': 'str'}, - 'backup_drive_manifest': {'key': 'properties.backupDriveManifest', 'type': 'bool'}, - 'drive_list': {'key': 'properties.driveList', 'type': '[DriveStatus]'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateJobParameters, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.cancel_requested = kwargs.get('cancel_requested', None) - self.state = kwargs.get('state', None) - self.return_address = kwargs.get('return_address', None) - self.return_shipping = kwargs.get('return_shipping', None) - self.delivery_package = kwargs.get('delivery_package', None) - self.log_level = kwargs.get('log_level', None) - self.backup_drive_manifest = kwargs.get('backup_drive_manifest', None) - self.drive_list = kwargs.get('drive_list', None) diff --git a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/models/_models_py3.py b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/models/_models_py3.py index 2ddeb31c5fcd..bd0def6be4a2 100644 --- a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/models/_models_py3.py @@ -20,15 +20,15 @@ class DeliveryPackageInformation(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param carrier_name: Required. The name of the carrier that is used to ship the import or - export drives. - :type carrier_name: str - :param tracking_number: Required. The tracking number of the package. - :type tracking_number: str - :param drive_count: The number of drives included in the package. - :type drive_count: long - :param ship_date: The date when the package is shipped. - :type ship_date: str + :ivar carrier_name: Required. The name of the carrier that is used to ship the import or export + drives. + :vartype carrier_name: str + :ivar tracking_number: Required. The tracking number of the package. + :vartype tracking_number: str + :ivar drive_count: The number of drives included in the package. + :vartype drive_count: long + :ivar ship_date: The date when the package is shipped. + :vartype ship_date: str """ _validation = { @@ -52,6 +52,17 @@ def __init__( ship_date: Optional[str] = None, **kwargs ): + """ + :keyword carrier_name: Required. The name of the carrier that is used to ship the import or + export drives. + :paramtype carrier_name: str + :keyword tracking_number: Required. The tracking number of the package. + :paramtype tracking_number: str + :keyword drive_count: The number of drives included in the package. + :paramtype drive_count: long + :keyword ship_date: The date when the package is shipped. + :paramtype ship_date: str + """ super(DeliveryPackageInformation, self).__init__(**kwargs) self.carrier_name = carrier_name self.tracking_number = tracking_number @@ -62,10 +73,10 @@ def __init__( class DriveBitLockerKey(msrest.serialization.Model): """BitLocker recovery key or password to the specified drive. - :param bit_locker_key: BitLocker recovery key or password. - :type bit_locker_key: str - :param drive_id: Drive ID. - :type drive_id: str + :ivar bit_locker_key: BitLocker recovery key or password. + :vartype bit_locker_key: str + :ivar drive_id: Drive ID. + :vartype drive_id: str """ _attribute_map = { @@ -80,6 +91,12 @@ def __init__( drive_id: Optional[str] = None, **kwargs ): + """ + :keyword bit_locker_key: BitLocker recovery key or password. + :paramtype bit_locker_key: str + :keyword drive_id: Drive ID. + :paramtype drive_id: str + """ super(DriveBitLockerKey, self).__init__(**kwargs) self.bit_locker_key = bit_locker_key self.drive_id = drive_id @@ -88,34 +105,35 @@ def __init__( class DriveStatus(msrest.serialization.Model): """Provides information about the drive's status. - :param drive_id: The drive's hardware serial number, without spaces. - :type drive_id: str - :param bit_locker_key: The BitLocker key used to encrypt the drive. - :type bit_locker_key: str - :param manifest_file: The relative path of the manifest file on the drive. - :type manifest_file: str - :param manifest_hash: The Base16-encoded MD5 hash of the manifest file on the drive. - :type manifest_hash: str - :param drive_header_hash: The drive header hash value. - :type drive_header_hash: str - :param state: The drive's current state. Possible values include: "Specified", "Received", - "NeverReceived", "Transferring", "Completed", "CompletedMoreInfo", "ShippedBack". - :type state: str or ~storage_import_export.models.DriveState - :param copy_status: Detailed status about the data transfer process. This field is not returned + :ivar drive_id: The drive's hardware serial number, without spaces. + :vartype drive_id: str + :ivar bit_locker_key: The BitLocker key used to encrypt the drive. + :vartype bit_locker_key: str + :ivar manifest_file: The relative path of the manifest file on the drive. + :vartype manifest_file: str + :ivar manifest_hash: The Base16-encoded MD5 hash of the manifest file on the drive. + :vartype manifest_hash: str + :ivar drive_header_hash: The drive header hash value. + :vartype drive_header_hash: str + :ivar state: The drive's current state. Possible values include: "Specified", "Received", + "NeverReceived", "Transferring", "Completed", "CompletedMoreInfo", "ShippedBack". Default + value: "Specified". + :vartype state: str or ~storage_import_export.models.DriveState + :ivar copy_status: Detailed status about the data transfer process. This field is not returned in the response until the drive is in the Transferring state. - :type copy_status: str - :param percent_complete: Percentage completed for the drive. - :type percent_complete: long - :param verbose_log_uri: A URI that points to the blob containing the verbose log for the data + :vartype copy_status: str + :ivar percent_complete: Percentage completed for the drive. + :vartype percent_complete: long + :ivar verbose_log_uri: A URI that points to the blob containing the verbose log for the data transfer operation. - :type verbose_log_uri: str - :param error_log_uri: A URI that points to the blob containing the error log for the data + :vartype verbose_log_uri: str + :ivar error_log_uri: A URI that points to the blob containing the error log for the data transfer operation. - :type error_log_uri: str - :param manifest_uri: A URI that points to the blob containing the drive manifest file. - :type manifest_uri: str - :param bytes_succeeded: Bytes successfully transferred for the drive. - :type bytes_succeeded: long + :vartype error_log_uri: str + :ivar manifest_uri: A URI that points to the blob containing the drive manifest file. + :vartype manifest_uri: str + :ivar bytes_succeeded: Bytes successfully transferred for the drive. + :vartype bytes_succeeded: long """ _attribute_map = { @@ -141,7 +159,7 @@ def __init__( manifest_file: Optional[str] = None, manifest_hash: Optional[str] = None, drive_header_hash: Optional[str] = None, - state: Optional[Union[str, "DriveState"]] = None, + state: Optional[Union[str, "DriveState"]] = "Specified", copy_status: Optional[str] = None, percent_complete: Optional[int] = None, verbose_log_uri: Optional[str] = None, @@ -150,6 +168,37 @@ def __init__( bytes_succeeded: Optional[int] = None, **kwargs ): + """ + :keyword drive_id: The drive's hardware serial number, without spaces. + :paramtype drive_id: str + :keyword bit_locker_key: The BitLocker key used to encrypt the drive. + :paramtype bit_locker_key: str + :keyword manifest_file: The relative path of the manifest file on the drive. + :paramtype manifest_file: str + :keyword manifest_hash: The Base16-encoded MD5 hash of the manifest file on the drive. + :paramtype manifest_hash: str + :keyword drive_header_hash: The drive header hash value. + :paramtype drive_header_hash: str + :keyword state: The drive's current state. Possible values include: "Specified", "Received", + "NeverReceived", "Transferring", "Completed", "CompletedMoreInfo", "ShippedBack". Default + value: "Specified". + :paramtype state: str or ~storage_import_export.models.DriveState + :keyword copy_status: Detailed status about the data transfer process. This field is not + returned in the response until the drive is in the Transferring state. + :paramtype copy_status: str + :keyword percent_complete: Percentage completed for the drive. + :paramtype percent_complete: long + :keyword verbose_log_uri: A URI that points to the blob containing the verbose log for the data + transfer operation. + :paramtype verbose_log_uri: str + :keyword error_log_uri: A URI that points to the blob containing the error log for the data + transfer operation. + :paramtype error_log_uri: str + :keyword manifest_uri: A URI that points to the blob containing the drive manifest file. + :paramtype manifest_uri: str + :keyword bytes_succeeded: Bytes successfully transferred for the drive. + :paramtype bytes_succeeded: long + """ super(DriveStatus, self).__init__(**kwargs) self.drive_id = drive_id self.bit_locker_key = bit_locker_key @@ -168,13 +217,13 @@ def __init__( class EncryptionKeyDetails(msrest.serialization.Model): """Specifies the encryption key properties. - :param kek_type: The type of kek encryption key. Possible values include: "MicrosoftManaged", + :ivar kek_type: The type of kek encryption key. Possible values include: "MicrosoftManaged", "CustomerManaged". Default value: "MicrosoftManaged". - :type kek_type: str or ~storage_import_export.models.EncryptionKekType - :param kek_url: Specifies the url for kek encryption key. - :type kek_url: str - :param kek_vault_resource_id: Specifies the keyvault resource id for kek encryption key. - :type kek_vault_resource_id: str + :vartype kek_type: str or ~storage_import_export.models.EncryptionKekType + :ivar kek_url: Specifies the url for kek encryption key. + :vartype kek_url: str + :ivar kek_vault_resource_id: Specifies the keyvault resource id for kek encryption key. + :vartype kek_vault_resource_id: str """ _attribute_map = { @@ -191,6 +240,15 @@ def __init__( kek_vault_resource_id: Optional[str] = None, **kwargs ): + """ + :keyword kek_type: The type of kek encryption key. Possible values include: "MicrosoftManaged", + "CustomerManaged". Default value: "MicrosoftManaged". + :paramtype kek_type: str or ~storage_import_export.models.EncryptionKekType + :keyword kek_url: Specifies the url for kek encryption key. + :paramtype kek_url: str + :keyword kek_vault_resource_id: Specifies the keyvault resource id for kek encryption key. + :paramtype kek_vault_resource_id: str + """ super(EncryptionKeyDetails, self).__init__(**kwargs) self.kek_type = kek_type self.kek_url = kek_url @@ -200,16 +258,16 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Response when errors occurred. - :param code: Provides information about the error code. - :type code: str - :param message: Provides information about the error message. - :type message: str - :param target: Provides information about the error target. - :type target: str - :param details: Describes the error details if present. - :type details: list[~storage_import_export.models.ErrorResponseErrorDetailsItem] - :param innererror: Inner error object if present. - :type innererror: any + :ivar code: Provides information about the error code. + :vartype code: str + :ivar message: Provides information about the error message. + :vartype message: str + :ivar target: Provides information about the error target. + :vartype target: str + :ivar details: Describes the error details if present. + :vartype details: list[~storage_import_export.models.ErrorResponseErrorDetailsItem] + :ivar innererror: Inner error object if present. + :vartype innererror: any """ _attribute_map = { @@ -230,6 +288,18 @@ def __init__( innererror: Optional[Any] = None, **kwargs ): + """ + :keyword code: Provides information about the error code. + :paramtype code: str + :keyword message: Provides information about the error message. + :paramtype message: str + :keyword target: Provides information about the error target. + :paramtype target: str + :keyword details: Describes the error details if present. + :paramtype details: list[~storage_import_export.models.ErrorResponseErrorDetailsItem] + :keyword innererror: Inner error object if present. + :paramtype innererror: any + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -241,12 +311,12 @@ def __init__( class ErrorResponseErrorDetailsItem(msrest.serialization.Model): """ErrorResponseErrorDetailsItem. - :param code: Provides information about the error code. - :type code: str - :param target: Provides information about the error target. - :type target: str - :param message: Provides information about the error message. - :type message: str + :ivar code: Provides information about the error code. + :vartype code: str + :ivar target: Provides information about the error target. + :vartype target: str + :ivar message: Provides information about the error message. + :vartype message: str """ _attribute_map = { @@ -263,6 +333,14 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Provides information about the error code. + :paramtype code: str + :keyword target: Provides information about the error target. + :paramtype target: str + :keyword message: Provides information about the error message. + :paramtype message: str + """ super(ErrorResponseErrorDetailsItem, self).__init__(**kwargs) self.code = code self.target = target @@ -272,14 +350,14 @@ def __init__( class Export(msrest.serialization.Model): """A property containing information about the blobs to be exported for an export job. This property is required for export jobs, but must not be specified for import jobs. - :param blob_list_blob_path: The relative URI to the block blob that contains the list of blob + :ivar blob_list_blob_path: The relative URI to the block blob that contains the list of blob paths or blob path prefixes as defined above, beginning with the container name. If the blob is in root container, the URI must begin with $root. - :type blob_list_blob_path: str - :param blob_path: A collection of blob-path strings. - :type blob_path: list[str] - :param blob_path_prefix: A collection of blob-prefix strings. - :type blob_path_prefix: list[str] + :vartype blob_list_blob_path: str + :ivar blob_path: A collection of blob-path strings. + :vartype blob_path: list[str] + :ivar blob_path_prefix: A collection of blob-prefix strings. + :vartype blob_path_prefix: list[str] """ _attribute_map = { @@ -296,6 +374,16 @@ def __init__( blob_path_prefix: Optional[List[str]] = None, **kwargs ): + """ + :keyword blob_list_blob_path: The relative URI to the block blob that contains the list of blob + paths or blob path prefixes as defined above, beginning with the container name. If the blob is + in root container, the URI must begin with $root. + :paramtype blob_list_blob_path: str + :keyword blob_path: A collection of blob-path strings. + :paramtype blob_path: list[str] + :keyword blob_path_prefix: A collection of blob-prefix strings. + :paramtype blob_path_prefix: list[str] + """ super(Export, self).__init__(**kwargs) self.blob_list_blob_path = blob_list_blob_path self.blob_path = blob_path @@ -305,8 +393,8 @@ def __init__( class GetBitLockerKeysResponse(msrest.serialization.Model): """GetBitLockerKeys response. - :param value: drive status. - :type value: list[~storage_import_export.models.DriveBitLockerKey] + :ivar value: drive status. + :vartype value: list[~storage_import_export.models.DriveBitLockerKey] """ _attribute_map = { @@ -319,6 +407,10 @@ def __init__( value: Optional[List["DriveBitLockerKey"]] = None, **kwargs ): + """ + :keyword value: drive status. + :paramtype value: list[~storage_import_export.models.DriveBitLockerKey] + """ super(GetBitLockerKeysResponse, self).__init__(**kwargs) self.value = value @@ -328,9 +420,9 @@ class IdentityDetails(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param type: The type of identity. Possible values include: "None", "SystemAssigned", + :ivar type: The type of identity. Possible values include: "None", "SystemAssigned", "UserAssigned". Default value: "None". - :type type: str or ~storage_import_export.models.IdentityType + :vartype type: str or ~storage_import_export.models.IdentityType :ivar principal_id: Specifies the principal id for the identity for the job. :vartype principal_id: str :ivar tenant_id: Specifies the tenant id for the identity for the job. @@ -354,6 +446,11 @@ def __init__( type: Optional[Union[str, "IdentityType"]] = "None", **kwargs ): + """ + :keyword type: The type of identity. Possible values include: "None", "SystemAssigned", + "UserAssigned". Default value: "None". + :paramtype type: str or ~storage_import_export.models.IdentityType + """ super(IdentityDetails, self).__init__(**kwargs) self.type = type self.principal_id = None @@ -363,54 +460,54 @@ def __init__( class JobDetails(msrest.serialization.Model): """Specifies the job properties. - :param storage_account_id: The resource identifier of the storage account where data will be + :ivar storage_account_id: The resource identifier of the storage account where data will be imported to or exported from. - :type storage_account_id: str - :param job_type: The type of job. - :type job_type: str - :param return_address: Specifies the return address information for the job. - :type return_address: ~storage_import_export.models.ReturnAddress - :param return_shipping: Specifies the return carrier and customer's account with the carrier. - :type return_shipping: ~storage_import_export.models.ReturnShipping - :param shipping_information: Contains information about the Microsoft datacenter to which the + :vartype storage_account_id: str + :ivar job_type: The type of job. + :vartype job_type: str + :ivar return_address: Specifies the return address information for the job. + :vartype return_address: ~storage_import_export.models.ReturnAddress + :ivar return_shipping: Specifies the return carrier and customer's account with the carrier. + :vartype return_shipping: ~storage_import_export.models.ReturnShipping + :ivar shipping_information: Contains information about the Microsoft datacenter to which the drives should be shipped. - :type shipping_information: ~storage_import_export.models.ShippingInformation - :param delivery_package: Contains information about the package being shipped by the customer - to the Microsoft data center. - :type delivery_package: ~storage_import_export.models.DeliveryPackageInformation - :param return_package: Contains information about the package being shipped from the Microsoft + :vartype shipping_information: ~storage_import_export.models.ShippingInformation + :ivar delivery_package: Contains information about the package being shipped by the customer to + the Microsoft data center. + :vartype delivery_package: ~storage_import_export.models.DeliveryPackageInformation + :ivar return_package: Contains information about the package being shipped from the Microsoft data center to the customer to return the drives. The format is the same as the deliveryPackage property above. This property is not included if the drives have not yet been returned. - :type return_package: ~storage_import_export.models.PackageInformation - :param diagnostics_path: The virtual blob directory to which the copy logs and backups of drive + :vartype return_package: ~storage_import_export.models.PackageInformation + :ivar diagnostics_path: The virtual blob directory to which the copy logs and backups of drive manifest files (if enabled) will be stored. - :type diagnostics_path: str - :param log_level: Default value is Error. Indicates whether error logging or verbose logging + :vartype diagnostics_path: str + :ivar log_level: Default value is Error. Indicates whether error logging or verbose logging will be enabled. - :type log_level: str - :param backup_drive_manifest: Default value is false. Indicates whether the manifest files on + :vartype log_level: str + :ivar backup_drive_manifest: Default value is false. Indicates whether the manifest files on the drives should be copied to block blobs. - :type backup_drive_manifest: bool - :param state: Current state of the job. - :type state: str - :param cancel_requested: Indicates whether a request has been submitted to cancel the job. - :type cancel_requested: bool - :param percent_complete: Overall percentage completed for the job. - :type percent_complete: long - :param incomplete_blob_list_uri: A blob path that points to a block blob containing a list of + :vartype backup_drive_manifest: bool + :ivar state: Current state of the job. + :vartype state: str + :ivar cancel_requested: Indicates whether a request has been submitted to cancel the job. + :vartype cancel_requested: bool + :ivar percent_complete: Overall percentage completed for the job. + :vartype percent_complete: long + :ivar incomplete_blob_list_uri: A blob path that points to a block blob containing a list of blob names that were not exported due to insufficient drive space. If all blobs were exported successfully, then this element is not included in the response. - :type incomplete_blob_list_uri: str - :param drive_list: List of up to ten drives that comprise the job. The drive list is a required + :vartype incomplete_blob_list_uri: str + :ivar drive_list: List of up to ten drives that comprise the job. The drive list is a required element for an import job; it is not specified for export jobs. - :type drive_list: list[~storage_import_export.models.DriveStatus] - :param export: A property containing information about the blobs to be exported for an export + :vartype drive_list: list[~storage_import_export.models.DriveStatus] + :ivar export: A property containing information about the blobs to be exported for an export job. This property is included for export jobs only. - :type export: ~storage_import_export.models.Export - :param provisioning_state: Specifies the provisioning state of the job. - :type provisioning_state: str - :param encryption_key: Contains information about the encryption key. - :type encryption_key: ~storage_import_export.models.EncryptionKeyDetails + :vartype export: ~storage_import_export.models.Export + :ivar provisioning_state: Specifies the provisioning state of the job. + :vartype provisioning_state: str + :ivar encryption_key: Contains information about the encryption key. + :vartype encryption_key: ~storage_import_export.models.EncryptionKeyDetails """ _attribute_map = { @@ -446,9 +543,9 @@ def __init__( return_package: Optional["PackageInformation"] = None, diagnostics_path: Optional[str] = None, log_level: Optional[str] = None, - backup_drive_manifest: Optional[bool] = None, - state: Optional[str] = None, - cancel_requested: Optional[bool] = None, + backup_drive_manifest: Optional[bool] = False, + state: Optional[str] = "Creating", + cancel_requested: Optional[bool] = False, percent_complete: Optional[int] = None, incomplete_blob_list_uri: Optional[str] = None, drive_list: Optional[List["DriveStatus"]] = None, @@ -457,6 +554,57 @@ def __init__( encryption_key: Optional["EncryptionKeyDetails"] = None, **kwargs ): + """ + :keyword storage_account_id: The resource identifier of the storage account where data will be + imported to or exported from. + :paramtype storage_account_id: str + :keyword job_type: The type of job. + :paramtype job_type: str + :keyword return_address: Specifies the return address information for the job. + :paramtype return_address: ~storage_import_export.models.ReturnAddress + :keyword return_shipping: Specifies the return carrier and customer's account with the carrier. + :paramtype return_shipping: ~storage_import_export.models.ReturnShipping + :keyword shipping_information: Contains information about the Microsoft datacenter to which the + drives should be shipped. + :paramtype shipping_information: ~storage_import_export.models.ShippingInformation + :keyword delivery_package: Contains information about the package being shipped by the customer + to the Microsoft data center. + :paramtype delivery_package: ~storage_import_export.models.DeliveryPackageInformation + :keyword return_package: Contains information about the package being shipped from the + Microsoft data center to the customer to return the drives. The format is the same as the + deliveryPackage property above. This property is not included if the drives have not yet been + returned. + :paramtype return_package: ~storage_import_export.models.PackageInformation + :keyword diagnostics_path: The virtual blob directory to which the copy logs and backups of + drive manifest files (if enabled) will be stored. + :paramtype diagnostics_path: str + :keyword log_level: Default value is Error. Indicates whether error logging or verbose logging + will be enabled. + :paramtype log_level: str + :keyword backup_drive_manifest: Default value is false. Indicates whether the manifest files on + the drives should be copied to block blobs. + :paramtype backup_drive_manifest: bool + :keyword state: Current state of the job. + :paramtype state: str + :keyword cancel_requested: Indicates whether a request has been submitted to cancel the job. + :paramtype cancel_requested: bool + :keyword percent_complete: Overall percentage completed for the job. + :paramtype percent_complete: long + :keyword incomplete_blob_list_uri: A blob path that points to a block blob containing a list of + blob names that were not exported due to insufficient drive space. If all blobs were exported + successfully, then this element is not included in the response. + :paramtype incomplete_blob_list_uri: str + :keyword drive_list: List of up to ten drives that comprise the job. The drive list is a + required element for an import job; it is not specified for export jobs. + :paramtype drive_list: list[~storage_import_export.models.DriveStatus] + :keyword export: A property containing information about the blobs to be exported for an export + job. This property is included for export jobs only. + :paramtype export: ~storage_import_export.models.Export + :keyword provisioning_state: Specifies the provisioning state of the job. + :paramtype provisioning_state: str + :keyword encryption_key: Contains information about the encryption key. + :paramtype encryption_key: ~storage_import_export.models.EncryptionKeyDetails + """ super(JobDetails, self).__init__(**kwargs) self.storage_account_id = storage_account_id self.job_type = job_type @@ -491,14 +639,14 @@ class JobResponse(msrest.serialization.Model): :vartype name: str :ivar type: Specifies the type of the job resource. :vartype type: str - :param location: Specifies the Azure location where the job is created. - :type location: str - :param tags: A set of tags. Specifies the tags that are assigned to the job. - :type tags: any - :param properties: Specifies the job properties. - :type properties: ~storage_import_export.models.JobDetails - :param identity: Specifies the job identity details. - :type identity: ~storage_import_export.models.IdentityDetails + :ivar location: Specifies the Azure location where the job is created. + :vartype location: str + :ivar tags: A set of tags. Specifies the tags that are assigned to the job. + :vartype tags: any + :ivar properties: Specifies the job properties. + :vartype properties: ~storage_import_export.models.JobDetails + :ivar identity: Specifies the job identity details. + :vartype identity: ~storage_import_export.models.IdentityDetails """ _validation = { @@ -528,6 +676,16 @@ def __init__( identity: Optional["IdentityDetails"] = None, **kwargs ): + """ + :keyword location: Specifies the Azure location where the job is created. + :paramtype location: str + :keyword tags: A set of tags. Specifies the tags that are assigned to the job. + :paramtype tags: any + :keyword properties: Specifies the job properties. + :paramtype properties: ~storage_import_export.models.JobDetails + :keyword identity: Specifies the job identity details. + :paramtype identity: ~storage_import_export.models.IdentityDetails + """ super(JobResponse, self).__init__(**kwargs) self.system_data = None self.id = None @@ -542,10 +700,10 @@ def __init__( class ListJobsResponse(msrest.serialization.Model): """List jobs response. - :param next_link: link to next batch of jobs. - :type next_link: str - :param value: Job list. - :type value: list[~storage_import_export.models.JobResponse] + :ivar next_link: link to next batch of jobs. + :vartype next_link: str + :ivar value: Job list. + :vartype value: list[~storage_import_export.models.JobResponse] """ _attribute_map = { @@ -560,6 +718,12 @@ def __init__( value: Optional[List["JobResponse"]] = None, **kwargs ): + """ + :keyword next_link: link to next batch of jobs. + :paramtype next_link: str + :keyword value: Job list. + :paramtype value: list[~storage_import_export.models.JobResponse] + """ super(ListJobsResponse, self).__init__(**kwargs) self.next_link = next_link self.value = value @@ -568,8 +732,8 @@ def __init__( class ListOperationsResponse(msrest.serialization.Model): """List operations response. - :param value: operations. - :type value: list[~storage_import_export.models.Operation] + :ivar value: operations. + :vartype value: list[~storage_import_export.models.Operation] """ _attribute_map = { @@ -582,6 +746,10 @@ def __init__( value: Optional[List["Operation"]] = None, **kwargs ): + """ + :keyword value: operations. + :paramtype value: list[~storage_import_export.models.Operation] + """ super(ListOperationsResponse, self).__init__(**kwargs) self.value = value @@ -589,44 +757,44 @@ def __init__( class Location(msrest.serialization.Model): """Provides information about an Azure data center location. - :param id: Specifies the resource identifier of the location. - :type id: str - :param name: Specifies the name of the location. Use List Locations to get all supported + :ivar id: Specifies the resource identifier of the location. + :vartype id: str + :ivar name: Specifies the name of the location. Use List Locations to get all supported locations. - :type name: str - :param type: Specifies the type of the location. - :type type: str - :param recipient_name: The recipient name to use when shipping the drives to the Azure data + :vartype name: str + :ivar type: Specifies the type of the location. + :vartype type: str + :ivar recipient_name: The recipient name to use when shipping the drives to the Azure data center. - :type recipient_name: str - :param street_address1: The first line of the street address to use when shipping the drives to + :vartype recipient_name: str + :ivar street_address1: The first line of the street address to use when shipping the drives to + the Azure data center. + :vartype street_address1: str + :ivar street_address2: The second line of the street address to use when shipping the drives to the Azure data center. - :type street_address1: str - :param street_address2: The second line of the street address to use when shipping the drives - to the Azure data center. - :type street_address2: str - :param city: The city name to use when shipping the drives to the Azure data center. - :type city: str - :param state_or_province: The state or province to use when shipping the drives to the Azure + :vartype street_address2: str + :ivar city: The city name to use when shipping the drives to the Azure data center. + :vartype city: str + :ivar state_or_province: The state or province to use when shipping the drives to the Azure data center. - :type state_or_province: str - :param postal_code: The postal code to use when shipping the drives to the Azure data center. - :type postal_code: str - :param country_or_region: The country or region to use when shipping the drives to the Azure + :vartype state_or_province: str + :ivar postal_code: The postal code to use when shipping the drives to the Azure data center. + :vartype postal_code: str + :ivar country_or_region: The country or region to use when shipping the drives to the Azure data center. - :type country_or_region: str - :param phone: The phone number for the Azure data center. - :type phone: str - :param additional_shipping_information: Additional shipping information for customer, specific + :vartype country_or_region: str + :ivar phone: The phone number for the Azure data center. + :vartype phone: str + :ivar additional_shipping_information: Additional shipping information for customer, specific to datacenter to which customer should send their disks. - :type additional_shipping_information: str - :param supported_carriers: A list of carriers that are supported at this location. - :type supported_carriers: list[str] - :param alternate_locations: A list of location IDs that should be used to ship shipping drives + :vartype additional_shipping_information: str + :ivar supported_carriers: A list of carriers that are supported at this location. + :vartype supported_carriers: list[str] + :ivar alternate_locations: A list of location IDs that should be used to ship shipping drives to for jobs created against the current location. If the current location is active, it will be part of the list. If it is temporarily closed due to maintenance, this list may contain other locations. - :type alternate_locations: list[str] + :vartype alternate_locations: list[str] """ _attribute_map = { @@ -665,6 +833,46 @@ def __init__( alternate_locations: Optional[List[str]] = None, **kwargs ): + """ + :keyword id: Specifies the resource identifier of the location. + :paramtype id: str + :keyword name: Specifies the name of the location. Use List Locations to get all supported + locations. + :paramtype name: str + :keyword type: Specifies the type of the location. + :paramtype type: str + :keyword recipient_name: The recipient name to use when shipping the drives to the Azure data + center. + :paramtype recipient_name: str + :keyword street_address1: The first line of the street address to use when shipping the drives + to the Azure data center. + :paramtype street_address1: str + :keyword street_address2: The second line of the street address to use when shipping the drives + to the Azure data center. + :paramtype street_address2: str + :keyword city: The city name to use when shipping the drives to the Azure data center. + :paramtype city: str + :keyword state_or_province: The state or province to use when shipping the drives to the Azure + data center. + :paramtype state_or_province: str + :keyword postal_code: The postal code to use when shipping the drives to the Azure data center. + :paramtype postal_code: str + :keyword country_or_region: The country or region to use when shipping the drives to the Azure + data center. + :paramtype country_or_region: str + :keyword phone: The phone number for the Azure data center. + :paramtype phone: str + :keyword additional_shipping_information: Additional shipping information for customer, + specific to datacenter to which customer should send their disks. + :paramtype additional_shipping_information: str + :keyword supported_carriers: A list of carriers that are supported at this location. + :paramtype supported_carriers: list[str] + :keyword alternate_locations: A list of location IDs that should be used to ship shipping + drives to for jobs created against the current location. If the current location is active, it + will be part of the list. If it is temporarily closed due to maintenance, this list may contain + other locations. + :paramtype alternate_locations: list[str] + """ super(Location, self).__init__(**kwargs) self.id = id self.name = name @@ -685,8 +893,8 @@ def __init__( class LocationsResponse(msrest.serialization.Model): """Locations response. - :param value: locations. - :type value: list[~storage_import_export.models.Location] + :ivar value: locations. + :vartype value: list[~storage_import_export.models.Location] """ _attribute_map = { @@ -699,6 +907,10 @@ def __init__( value: Optional[List["Location"]] = None, **kwargs ): + """ + :keyword value: locations. + :paramtype value: list[~storage_import_export.models.Location] + """ super(LocationsResponse, self).__init__(**kwargs) self.value = value @@ -708,16 +920,16 @@ class Operation(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the operation. - :type name: str - :param provider: The resource provider name to which the operation belongs. - :type provider: str - :param resource: The name of the resource to which the operation belongs. - :type resource: str - :param operation: The display name of the operation. - :type operation: str - :param description: Short description of the operation. - :type description: str + :ivar name: Required. Name of the operation. + :vartype name: str + :ivar provider: The resource provider name to which the operation belongs. + :vartype provider: str + :ivar resource: The name of the resource to which the operation belongs. + :vartype resource: str + :ivar operation: The display name of the operation. + :vartype operation: str + :ivar description: Short description of the operation. + :vartype description: str """ _validation = { @@ -742,6 +954,18 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. Name of the operation. + :paramtype name: str + :keyword provider: The resource provider name to which the operation belongs. + :paramtype provider: str + :keyword resource: The name of the resource to which the operation belongs. + :paramtype resource: str + :keyword operation: The display name of the operation. + :paramtype operation: str + :keyword description: Short description of the operation. + :paramtype description: str + """ super(Operation, self).__init__(**kwargs) self.name = name self.provider = provider @@ -755,15 +979,15 @@ class PackageInformation(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param carrier_name: Required. The name of the carrier that is used to ship the import or - export drives. - :type carrier_name: str - :param tracking_number: Required. The tracking number of the package. - :type tracking_number: str - :param drive_count: Required. The number of drives included in the package. - :type drive_count: long - :param ship_date: Required. The date when the package is shipped. - :type ship_date: str + :ivar carrier_name: Required. The name of the carrier that is used to ship the import or export + drives. + :vartype carrier_name: str + :ivar tracking_number: Required. The tracking number of the package. + :vartype tracking_number: str + :ivar drive_count: Required. The number of drives included in the package. + :vartype drive_count: long + :ivar ship_date: Required. The date when the package is shipped. + :vartype ship_date: str """ _validation = { @@ -789,6 +1013,17 @@ def __init__( ship_date: str, **kwargs ): + """ + :keyword carrier_name: Required. The name of the carrier that is used to ship the import or + export drives. + :paramtype carrier_name: str + :keyword tracking_number: Required. The tracking number of the package. + :paramtype tracking_number: str + :keyword drive_count: Required. The number of drives included in the package. + :paramtype drive_count: long + :keyword ship_date: Required. The date when the package is shipped. + :paramtype ship_date: str + """ super(PackageInformation, self).__init__(**kwargs) self.carrier_name = carrier_name self.tracking_number = tracking_number @@ -799,12 +1034,12 @@ def __init__( class PutJobParameters(msrest.serialization.Model): """Put Job parameters. - :param location: Specifies the supported Azure location where the job should be created. - :type location: str - :param tags: A set of tags. Specifies the tags that will be assigned to the job. - :type tags: any - :param properties: Specifies the job properties. - :type properties: ~storage_import_export.models.JobDetails + :ivar location: Specifies the supported Azure location where the job should be created. + :vartype location: str + :ivar tags: A set of tags. Specifies the tags that will be assigned to the job. + :vartype tags: any + :ivar properties: Specifies the job properties. + :vartype properties: ~storage_import_export.models.JobDetails """ _attribute_map = { @@ -821,6 +1056,14 @@ def __init__( properties: Optional["JobDetails"] = None, **kwargs ): + """ + :keyword location: Specifies the supported Azure location where the job should be created. + :paramtype location: str + :keyword tags: A set of tags. Specifies the tags that will be assigned to the job. + :paramtype tags: any + :keyword properties: Specifies the job properties. + :paramtype properties: ~storage_import_export.models.JobDetails + """ super(PutJobParameters, self).__init__(**kwargs) self.location = location self.tags = tags @@ -832,26 +1075,26 @@ class ReturnAddress(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param recipient_name: Required. The name of the recipient who will receive the hard drives - when they are returned. - :type recipient_name: str - :param street_address1: Required. The first line of the street address to use when returning - the drives. - :type street_address1: str - :param street_address2: The second line of the street address to use when returning the drives. - :type street_address2: str - :param city: Required. The city name to use when returning the drives. - :type city: str - :param state_or_province: The state or province to use when returning the drives. - :type state_or_province: str - :param postal_code: Required. The postal code to use when returning the drives. - :type postal_code: str - :param country_or_region: Required. The country or region to use when returning the drives. - :type country_or_region: str - :param phone: Required. Phone number of the recipient of the returned drives. - :type phone: str - :param email: Required. Email address of the recipient of the returned drives. - :type email: str + :ivar recipient_name: Required. The name of the recipient who will receive the hard drives when + they are returned. + :vartype recipient_name: str + :ivar street_address1: Required. The first line of the street address to use when returning the + drives. + :vartype street_address1: str + :ivar street_address2: The second line of the street address to use when returning the drives. + :vartype street_address2: str + :ivar city: Required. The city name to use when returning the drives. + :vartype city: str + :ivar state_or_province: The state or province to use when returning the drives. + :vartype state_or_province: str + :ivar postal_code: Required. The postal code to use when returning the drives. + :vartype postal_code: str + :ivar country_or_region: Required. The country or region to use when returning the drives. + :vartype country_or_region: str + :ivar phone: Required. Phone number of the recipient of the returned drives. + :vartype phone: str + :ivar email: Required. Email address of the recipient of the returned drives. + :vartype email: str """ _validation = { @@ -890,6 +1133,29 @@ def __init__( state_or_province: Optional[str] = None, **kwargs ): + """ + :keyword recipient_name: Required. The name of the recipient who will receive the hard drives + when they are returned. + :paramtype recipient_name: str + :keyword street_address1: Required. The first line of the street address to use when returning + the drives. + :paramtype street_address1: str + :keyword street_address2: The second line of the street address to use when returning the + drives. + :paramtype street_address2: str + :keyword city: Required. The city name to use when returning the drives. + :paramtype city: str + :keyword state_or_province: The state or province to use when returning the drives. + :paramtype state_or_province: str + :keyword postal_code: Required. The postal code to use when returning the drives. + :paramtype postal_code: str + :keyword country_or_region: Required. The country or region to use when returning the drives. + :paramtype country_or_region: str + :keyword phone: Required. Phone number of the recipient of the returned drives. + :paramtype phone: str + :keyword email: Required. Email address of the recipient of the returned drives. + :paramtype email: str + """ super(ReturnAddress, self).__init__(**kwargs) self.recipient_name = recipient_name self.street_address1 = street_address1 @@ -907,10 +1173,10 @@ class ReturnShipping(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param carrier_name: Required. The carrier's name. - :type carrier_name: str - :param carrier_account_number: Required. The customer's account number with the carrier. - :type carrier_account_number: str + :ivar carrier_name: Required. The carrier's name. + :vartype carrier_name: str + :ivar carrier_account_number: Required. The customer's account number with the carrier. + :vartype carrier_account_number: str """ _validation = { @@ -930,6 +1196,12 @@ def __init__( carrier_account_number: str, **kwargs ): + """ + :keyword carrier_name: Required. The carrier's name. + :paramtype carrier_name: str + :keyword carrier_account_number: Required. The customer's account number with the carrier. + :paramtype carrier_account_number: str + """ super(ReturnShipping, self).__init__(**kwargs) self.carrier_name = carrier_name self.carrier_account_number = carrier_account_number @@ -940,23 +1212,23 @@ class ShippingInformation(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param recipient_name: The name of the recipient who will receive the hard drives when they are + :ivar recipient_name: The name of the recipient who will receive the hard drives when they are returned. - :type recipient_name: str - :param street_address1: The first line of the street address to use when returning the drives. - :type street_address1: str - :param street_address2: The second line of the street address to use when returning the drives. - :type street_address2: str - :param city: The city name to use when returning the drives. - :type city: str - :param state_or_province: The state or province to use when returning the drives. - :type state_or_province: str - :param postal_code: The postal code to use when returning the drives. - :type postal_code: str - :param country_or_region: The country or region to use when returning the drives. - :type country_or_region: str - :param phone: Phone number of the recipient of the returned drives. - :type phone: str + :vartype recipient_name: str + :ivar street_address1: The first line of the street address to use when returning the drives. + :vartype street_address1: str + :ivar street_address2: The second line of the street address to use when returning the drives. + :vartype street_address2: str + :ivar city: The city name to use when returning the drives. + :vartype city: str + :ivar state_or_province: The state or province to use when returning the drives. + :vartype state_or_province: str + :ivar postal_code: The postal code to use when returning the drives. + :vartype postal_code: str + :ivar country_or_region: The country or region to use when returning the drives. + :vartype country_or_region: str + :ivar phone: Phone number of the recipient of the returned drives. + :vartype phone: str :ivar additional_information: Additional shipping information for customer, specific to datacenter to which customer should send their disks. :vartype additional_information: str @@ -991,6 +1263,27 @@ def __init__( phone: Optional[str] = None, **kwargs ): + """ + :keyword recipient_name: The name of the recipient who will receive the hard drives when they + are returned. + :paramtype recipient_name: str + :keyword street_address1: The first line of the street address to use when returning the + drives. + :paramtype street_address1: str + :keyword street_address2: The second line of the street address to use when returning the + drives. + :paramtype street_address2: str + :keyword city: The city name to use when returning the drives. + :paramtype city: str + :keyword state_or_province: The state or province to use when returning the drives. + :paramtype state_or_province: str + :keyword postal_code: The postal code to use when returning the drives. + :paramtype postal_code: str + :keyword country_or_region: The country or region to use when returning the drives. + :paramtype country_or_region: str + :keyword phone: Phone number of the recipient of the returned drives. + :paramtype phone: str + """ super(ShippingInformation, self).__init__(**kwargs) self.recipient_name = recipient_name self.street_address1 = street_address1 @@ -1006,20 +1299,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_import_export.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_import_export.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_import_export.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_import_export.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -1042,6 +1335,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_import_export.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_import_export.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 @@ -1054,30 +1363,30 @@ def __init__( class UpdateJobParameters(msrest.serialization.Model): """Update Job parameters. - :param tags: A set of tags. Specifies the tags that will be assigned to the job. - :type tags: any - :param cancel_requested: If specified, the value must be true. The service will attempt to + :ivar tags: A set of tags. Specifies the tags that will be assigned to the job. + :vartype tags: any + :ivar cancel_requested: If specified, the value must be true. The service will attempt to cancel the job. - :type cancel_requested: bool - :param state: If specified, the value must be Shipping, which tells the Import/Export service + :vartype cancel_requested: bool + :ivar state: If specified, the value must be Shipping, which tells the Import/Export service that the package for the job has been shipped. The ReturnAddress and DeliveryPackage properties must have been set either in this request or in a previous request, otherwise the request will fail. - :type state: str - :param return_address: Specifies the return address information for the job. - :type return_address: ~storage_import_export.models.ReturnAddress - :param return_shipping: Specifies the return carrier and customer's account with the carrier. - :type return_shipping: ~storage_import_export.models.ReturnShipping - :param delivery_package: Contains information about the package being shipped by the customer - to the Microsoft data center. - :type delivery_package: ~storage_import_export.models.DeliveryPackageInformation - :param log_level: Indicates whether error logging or verbose logging is enabled. - :type log_level: str - :param backup_drive_manifest: Indicates whether the manifest files on the drives should be + :vartype state: str + :ivar return_address: Specifies the return address information for the job. + :vartype return_address: ~storage_import_export.models.ReturnAddress + :ivar return_shipping: Specifies the return carrier and customer's account with the carrier. + :vartype return_shipping: ~storage_import_export.models.ReturnShipping + :ivar delivery_package: Contains information about the package being shipped by the customer to + the Microsoft data center. + :vartype delivery_package: ~storage_import_export.models.DeliveryPackageInformation + :ivar log_level: Indicates whether error logging or verbose logging is enabled. + :vartype log_level: str + :ivar backup_drive_manifest: Indicates whether the manifest files on the drives should be copied to block blobs. - :type backup_drive_manifest: bool - :param drive_list: List of drives that comprise the job. - :type drive_list: list[~storage_import_export.models.DriveStatus] + :vartype backup_drive_manifest: bool + :ivar drive_list: List of drives that comprise the job. + :vartype drive_list: list[~storage_import_export.models.DriveStatus] """ _attribute_map = { @@ -1096,16 +1405,42 @@ def __init__( self, *, tags: Optional[Any] = None, - cancel_requested: Optional[bool] = None, + cancel_requested: Optional[bool] = False, state: Optional[str] = None, return_address: Optional["ReturnAddress"] = None, return_shipping: Optional["ReturnShipping"] = None, delivery_package: Optional["DeliveryPackageInformation"] = None, log_level: Optional[str] = None, - backup_drive_manifest: Optional[bool] = None, + backup_drive_manifest: Optional[bool] = False, drive_list: Optional[List["DriveStatus"]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Specifies the tags that will be assigned to the job. + :paramtype tags: any + :keyword cancel_requested: If specified, the value must be true. The service will attempt to + cancel the job. + :paramtype cancel_requested: bool + :keyword state: If specified, the value must be Shipping, which tells the Import/Export service + that the package for the job has been shipped. The ReturnAddress and DeliveryPackage properties + must have been set either in this request or in a previous request, otherwise the request will + fail. + :paramtype state: str + :keyword return_address: Specifies the return address information for the job. + :paramtype return_address: ~storage_import_export.models.ReturnAddress + :keyword return_shipping: Specifies the return carrier and customer's account with the carrier. + :paramtype return_shipping: ~storage_import_export.models.ReturnShipping + :keyword delivery_package: Contains information about the package being shipped by the customer + to the Microsoft data center. + :paramtype delivery_package: ~storage_import_export.models.DeliveryPackageInformation + :keyword log_level: Indicates whether error logging or verbose logging is enabled. + :paramtype log_level: str + :keyword backup_drive_manifest: Indicates whether the manifest files on the drives should be + copied to block blobs. + :paramtype backup_drive_manifest: bool + :keyword drive_list: List of drives that comprise the job. + :paramtype drive_list: list[~storage_import_export.models.DriveStatus] + """ super(UpdateJobParameters, self).__init__(**kwargs) self.tags = tags self.cancel_requested = cancel_requested diff --git a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/models/_storage_import_export_enums.py b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/models/_storage_import_export_enums.py index 397faf89d478..f7dbf5c11361 100644 --- a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/models/_storage_import_export_enums.py +++ b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/models/_storage_import_export_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 CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -35,7 +20,7 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DriveState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DriveState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The drive's current state. """ @@ -47,14 +32,14 @@ class DriveState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): COMPLETED_MORE_INFO = "CompletedMoreInfo" SHIPPED_BACK = "ShippedBack" -class EncryptionKekType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionKekType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of kek encryption key """ MICROSOFT_MANAGED = "MicrosoftManaged" CUSTOMER_MANAGED = "CustomerManaged" -class IdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity """ diff --git a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/operations/_bit_locker_keys_operations.py b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/operations/_bit_locker_keys_operations.py index c422ab190fa3..441369cb041c 100644 --- a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/operations/_bit_locker_keys_operations.py +++ b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/operations/_bit_locker_keys_operations.py @@ -5,23 +5,64 @@ # 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( + job_name: str, + subscription_id: str, + resource_group_name: str, + *, + accept_language: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ImportExport/jobs/{jobName}/listBitLockerKeys') + path_format_arguments = { + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, '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] + if accept_language is not None: + header_parameters['Accept-Language'] = _SERIALIZER.header("accept_language", accept_language, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class BitLockerKeysOperations(object): """BitLockerKeysOperations operations. @@ -45,13 +86,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - job_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.GetBitLockerKeysResponse"] + job_name: str, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.GetBitLockerKeysResponse"]: """Returns the BitLocker Keys for all drives in the specified job. :param job_name: The name of the import/export job. @@ -60,7 +101,8 @@ def list( within the user subscription. :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 GetBitLockerKeysResponse or the result of cls(response) + :return: An iterator like instance of either GetBitLockerKeysResponse or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~storage_import_export.models.GetBitLockerKeysResponse] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -69,38 +111,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if self._config.accept_language is not None: - header_parameters['Accept-Language'] = self._serialize.header("self._config.accept_language", self._config.accept_language, 'str') - 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 = { - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_request( + job_name=job_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + accept_language=self._config.accept_language, + 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( + job_name=job_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + accept_language=self._config.accept_language, + 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('GetBitLockerKeysResponse', pipeline_response) + deserialized = self._deserialize("GetBitLockerKeysResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,12 +152,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/operations/_jobs_operations.py b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/operations/_jobs_operations.py index 6555d5aa4e49..4cfd7fe7bfd7 100644 --- a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/operations/_jobs_operations.py +++ b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/operations/_jobs_operations.py @@ -5,23 +5,285 @@ # 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.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, 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_by_subscription_request( + subscription_id: str, + *, + top: Optional[int] = None, + filter: Optional[str] = None, + accept_language: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ImportExport/jobs') + 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'long') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if accept_language is not None: + header_parameters['Accept-Language'] = _SERIALIZER.header("accept_language", accept_language, 'str') + 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( + subscription_id: str, + resource_group_name: str, + *, + top: Optional[int] = None, + filter: Optional[str] = None, + accept_language: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ImportExport/jobs') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'long') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if accept_language is not None: + header_parameters['Accept-Language'] = _SERIALIZER.header("accept_language", accept_language, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + job_name: str, + subscription_id: str, + resource_group_name: str, + *, + accept_language: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ImportExport/jobs/{jobName}') + path_format_arguments = { + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, '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] + if accept_language is not None: + header_parameters['Accept-Language'] = _SERIALIZER.header("accept_language", accept_language, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + job_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + accept_language: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ImportExport/jobs/{jobName}') + path_format_arguments = { + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, '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] + if accept_language is not None: + header_parameters['Accept-Language'] = _SERIALIZER.header("accept_language", accept_language, 'str') + 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_create_request( + job_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + accept_language: Optional[str] = None, + client_tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ImportExport/jobs/{jobName}') + path_format_arguments = { + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, '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] + if accept_language is not None: + header_parameters['Accept-Language'] = _SERIALIZER.header("accept_language", accept_language, 'str') + if client_tenant_id is not None: + header_parameters['x-ms-client-tenant-id'] = _SERIALIZER.header("client_tenant_id", client_tenant_id, 'str') + 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_delete_request( + job_name: str, + subscription_id: str, + resource_group_name: str, + *, + accept_language: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ImportExport/jobs/{jobName}') + path_format_arguments = { + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, '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] + if accept_language is not None: + header_parameters['Accept-Language'] = _SERIALIZER.header("accept_language", accept_language, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class JobsOperations(object): """JobsOperations operations. @@ -45,13 +307,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscription( self, - top=None, # type: Optional[int] - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ListJobsResponse"] + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ListJobsResponse"]: """Returns all active and completed jobs in a subscription. :param top: An integer value that specifies how many jobs at most should be returned. The value @@ -69,40 +331,35 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if self._config.accept_language is not None: - header_parameters['Accept-Language'] = self._serialize.header("self._config.accept_language", self._config.accept_language, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'long') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - 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_subscription_request( + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + accept_language=self._config.accept_language, + template_url=self.list_by_subscription.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_subscription_request( + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + accept_language=self._config.accept_language, + 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('ListJobsResponse', pipeline_response) + deserialized = self._deserialize("ListJobsResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -115,25 +372,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ImportExport/jobs'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - top=None, # type: Optional[int] - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ListJobsResponse"] + resource_group_name: str, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ListJobsResponse"]: """Returns all active and completed jobs in a resource group. :param resource_group_name: The resource group name uniquely identifies the resource group @@ -154,41 +412,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if self._config.accept_language is not None: - header_parameters['Accept-Language'] = self._serialize.header("self._config.accept_language", self._config.accept_language, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'long') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - 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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + top=top, + filter=filter, + accept_language=self._config.accept_language, + 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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + top=top, + filter=filter, + accept_language=self._config.accept_language, + 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('ListJobsResponse', pipeline_response) + deserialized = self._deserialize("ListJobsResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -201,24 +455,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ImportExport/jobs'} # type: ignore + @distributed_trace def get( self, - job_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.JobResponse" + job_name: str, + resource_group_name: str, + **kwargs: Any + ) -> "_models.JobResponse": """Gets information about an existing job. :param job_name: The name of the import/export job. @@ -236,35 +491,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if self._config.accept_language is not None: - header_parameters['Accept-Language'] = self._serialize.header("self._config.accept_language", self._config.accept_language, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + job_name=job_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + accept_language=self._config.accept_language, + 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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -273,16 +517,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ImportExport/jobs/{jobName}'} # type: ignore + + @distributed_trace def update( self, - job_name, # type: str - resource_group_name, # type: str - body, # type: "_models.UpdateJobParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.JobResponse" + job_name: str, + resource_group_name: str, + body: "_models.UpdateJobParameters", + **kwargs: Any + ) -> "_models.JobResponse": """Updates specific properties of a job. You can call this operation to notify the Import/Export service that the hard drives comprising the import or export job have been shipped to the Microsoft data center. It can also be used to cancel an existing job. @@ -304,40 +550,29 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if self._config.accept_language is not None: - header_parameters['Accept-Language'] = self._serialize.header("self._config.accept_language", self._config.accept_language, 'str') - 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] - body_content = self._serialize.body(body, 'UpdateJobParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'UpdateJobParameters') + + request = build_update_request( + job_name=job_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + accept_language=self._config.accept_language, + 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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -346,17 +581,19 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ImportExport/jobs/{jobName}'} # type: ignore + + @distributed_trace def create( self, - job_name, # type: str - resource_group_name, # type: str - body, # type: "_models.PutJobParameters" - client_tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.JobResponse" + job_name: str, + resource_group_name: str, + body: "_models.PutJobParameters", + client_tenant_id: Optional[str] = None, + **kwargs: Any + ) -> "_models.JobResponse": """Creates a new job or updates an existing job in the specified subscription. :param job_name: The name of the import/export job. @@ -378,42 +615,30 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if self._config.accept_language is not None: - header_parameters['Accept-Language'] = self._serialize.header("self._config.accept_language", self._config.accept_language, 'str') - if client_tenant_id is not None: - header_parameters['x-ms-client-tenant-id'] = self._serialize.header("client_tenant_id", client_tenant_id, 'str') - 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] - body_content = self._serialize.body(body, 'PutJobParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'PutJobParameters') + + request = build_create_request( + job_name=job_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + accept_language=self._config.accept_language, + client_tenant_id=client_tenant_id, + template_url=self.create.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, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -426,15 +651,17 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ImportExport/jobs/{jobName}'} # type: ignore + + @distributed_trace def delete( self, - job_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + job_name: str, + resource_group_name: str, + **kwargs: Any + ) -> None: """Deletes an existing job. Only jobs in the Creating or Completed states can be deleted. :param job_name: The name of the import/export job. @@ -452,38 +679,28 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if self._config.accept_language is not None: - header_parameters['Accept-Language'] = self._serialize.header("self._config.accept_language", self._config.accept_language, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + job_name=job_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + accept_language=self._config.accept_language, + template_url=self.delete.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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ImportExport/jobs/{jobName}'} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/operations/_locations_operations.py b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/operations/_locations_operations.py index 15f211adcfe3..7c9bbf6e1a2c 100644 --- a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/operations/_locations_operations.py +++ b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/operations/_locations_operations.py @@ -5,23 +5,89 @@ # 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( + *, + accept_language: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.ImportExport/locations') + + # 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 accept_language is not None: + header_parameters['Accept-Language'] = _SERIALIZER.header("accept_language", accept_language, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + location_name: str, + *, + accept_language: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.ImportExport/locations/{locationName}') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, '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] + if accept_language is not None: + header_parameters['Accept-Language'] = _SERIALIZER.header("accept_language", accept_language, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class LocationsOperations(object): """LocationsOperations operations. @@ -45,11 +111,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.LocationsResponse"] + **kwargs: Any + ) -> Iterable["_models.LocationsResponse"]: """Returns a list of locations to which you can ship the disks associated with an import or export job. A location is a Microsoft data center region. @@ -63,32 +129,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if self._config.accept_language is not None: - header_parameters['Accept-Language'] = self._serialize.header("self._config.accept_language", self._config.accept_language, 'str') - 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( + accept_language=self._config.accept_language, + 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( + accept_language=self._config.accept_language, + 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('LocationsResponse', pipeline_response) + deserialized = self._deserialize("LocationsResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,23 +164,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/providers/Microsoft.ImportExport/locations'} # type: ignore + @distributed_trace def get( self, - location_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Location" + location_name: str, + **kwargs: Any + ) -> "_models.Location": """Returns the details about a location to which you can ship the disks associated with an import or export job. A location is an Azure region. @@ -133,33 +197,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if self._config.accept_language is not None: - header_parameters['Accept-Language'] = self._serialize.header("self._config.accept_language", self._config.accept_language, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + location_name=location_name, + accept_language=self._config.accept_language, + 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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Location', pipeline_response) @@ -168,4 +221,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.ImportExport/locations/{locationName}'} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/operations/_operations.py b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/operations/_operations.py index 8675e33b65ce..e88b073cfc51 100644 --- a/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storageimportexport/azure/mgmt/storageimportexport/operations/_operations.py @@ -5,23 +5,54 @@ # 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( + *, + accept_language: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.ImportExport/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] + if accept_language is not None: + header_parameters['Accept-Language'] = _SERIALIZER.header("accept_language", accept_language, 'str') + 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,15 +76,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ListOperationsResponse"] + **kwargs: Any + ) -> Iterable["_models.ListOperationsResponse"]: """Returns the list of operations supported by the import/export resource provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListOperationsResponse or the result of cls(response) + :return: An iterator like instance of either ListOperationsResponse or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~storage_import_export.models.ListOperationsResponse] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -62,32 +94,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if self._config.accept_language is not None: - header_parameters['Accept-Language'] = self._serialize.header("self._config.accept_language", self._config.accept_language, 'str') - 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( + accept_language=self._config.accept_language, + 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( + accept_language=self._config.accept_language, + 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('ListOperationsResponse', pipeline_response) + deserialized = self._deserialize("ListOperationsResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -100,12 +129,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/storage/azure-mgmt-storagesync/_meta.json b/sdk/storage/azure-mgmt-storagesync/_meta.json index 118b09547900..28c0218324c9 100644 --- a/sdk/storage/azure-mgmt-storagesync/_meta.json +++ b/sdk/storage/azure-mgmt-storagesync/_meta.json @@ -1,8 +1,11 @@ { - "autorest": "3.0.6369", - "use": "@autorest/python@5.6.2", - "commit": "18ed65c7581a1142c0015451e4d61ef0a3797268", + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "2ab4371edba33c23e8d680ed2bf6f98705b5cadb", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/storagesync/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.6.2 --version=3.0.6369", + "autorest_command": "autorest specification/storagesync/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/storagesync/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/__init__.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/__init__.py index ab897e67abbf..67e510c0757c 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/__init__.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MicrosoftStorageSync'] -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-storagesync/azure/mgmt/storagesync/_configuration.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/_configuration.py index cca075a91e7c..52f77b8e1fe5 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/_configuration.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/_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,16 +33,15 @@ class MicrosoftStorageSyncConfiguration(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(MicrosoftStorageSyncConfiguration, 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(MicrosoftStorageSyncConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -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-storagesync/azure/mgmt/storagesync/_metadata.json b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/_metadata.json index 36d5a7c7db39..9939477bdff0 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/_metadata.json +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/_metadata.json @@ -5,13 +5,13 @@ "name": "MicrosoftStorageSync", "filename": "_microsoft_storage_sync", "description": "Microsoft Storage Sync Service API.", - "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\": [\"MicrosoftStorageSyncConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "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\": [\"MicrosoftStorageSyncConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "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\": [\"MicrosoftStorageSyncConfiguration\"], \"._operations_mixin\": [\"MicrosoftStorageSyncOperationsMixin\"]}}, \"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\": [\"MicrosoftStorageSyncConfiguration\"], \"._operations_mixin\": [\"MicrosoftStorageSyncOperationsMixin\"]}}, \"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,11 +91,10 @@ "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", @@ -110,9 +109,21 @@ "operation_status": "OperationStatusOperations" }, "operation_mixins": { - "sync_imports": "None", - "async_imports": "None", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}}", "operations": { + "location_operation_status" : { + "sync": { + "signature": "def location_operation_status(\n self,\n location_name, # type: str\n operation_id, # type: str\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.LocationOperationStatus\"\n", + "doc": "\"\"\"Get Operation status.\n\n:param location_name: The desired region to obtain information from.\n:type location_name: str\n:param operation_id: operation Id.\n:type operation_id: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: LocationOperationStatus, or the result of cls(response)\n:rtype: ~azure.mgmt.storagesync.models.LocationOperationStatus\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def location_operation_status(\n self,\n location_name: str,\n operation_id: str,\n **kwargs: Any\n) -\u003e \"_models.LocationOperationStatus\":\n", + "doc": "\"\"\"Get Operation status.\n\n:param location_name: The desired region to obtain information from.\n:type location_name: str\n:param operation_id: operation Id.\n:type operation_id: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: LocationOperationStatus, or the result of cls(response)\n:rtype: ~azure.mgmt.storagesync.models.LocationOperationStatus\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "location_name, operation_id" + } } } } \ No newline at end of file diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/_microsoft_storage_sync.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/_microsoft_storage_sync.py index ac8ce46c988a..a99ec3f6e172 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/_microsoft_storage_sync.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/_microsoft_storage_sync.py @@ -6,32 +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 MicrosoftStorageSyncConfiguration +from .operations import CloudEndpointsOperations, MicrosoftStorageSyncOperationsMixin, OperationStatusOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, RegisteredServersOperations, ServerEndpointsOperations, StorageSyncServicesOperations, SyncGroupsOperations, WorkflowsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential -from ._configuration import MicrosoftStorageSyncConfiguration -from .operations import Operations -from .operations import StorageSyncServicesOperations -from .operations import PrivateLinkResourcesOperations -from .operations import PrivateEndpointConnectionsOperations -from .operations import SyncGroupsOperations -from .operations import CloudEndpointsOperations -from .operations import ServerEndpointsOperations -from .operations import RegisteredServersOperations -from .operations import WorkflowsOperations -from .operations import OperationStatusOperations -from . import models - - -class MicrosoftStorageSync(object): +class MicrosoftStorageSync(MicrosoftStorageSyncOperationsMixin): """Microsoft Storage Sync Service API. :ivar operations: Operations operations @@ -39,9 +29,11 @@ class MicrosoftStorageSync(object): :ivar storage_sync_services: StorageSyncServicesOperations operations :vartype storage_sync_services: azure.mgmt.storagesync.operations.StorageSyncServicesOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: azure.mgmt.storagesync.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: + azure.mgmt.storagesync.operations.PrivateLinkResourcesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.storagesync.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.storagesync.operations.PrivateEndpointConnectionsOperations :ivar sync_groups: SyncGroupsOperations operations :vartype sync_groups: azure.mgmt.storagesync.operations.SyncGroupsOperations :ivar cloud_endpoints: CloudEndpointsOperations operations @@ -58,48 +50,63 @@ class MicrosoftStorageSync(object): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :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 = MicrosoftStorageSyncConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = MicrosoftStorageSyncConfiguration(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.storage_sync_services = StorageSyncServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sync_groups = SyncGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.cloud_endpoints = CloudEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_endpoints = ServerEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) + self.registered_servers = RegisteredServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.workflows = WorkflowsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.storage_sync_services = StorageSyncServicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.sync_groups = SyncGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.cloud_endpoints = CloudEndpointsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_endpoints = ServerEndpointsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.registered_servers = RegisteredServersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.workflows = WorkflowsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_status = OperationStatusOperations( - self._client, self._config, self._serialize, self._deserialize) + 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-storagesync/azure/mgmt/storagesync/_patch.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/_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-storagesync/azure/mgmt/storagesync/_vendor.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/_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-storagesync/azure/mgmt/storagesync/_version.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/_version.py index c47f66669f1b..e5754a47ce68 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/_version.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/__init__.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/__init__.py index 39f85d7fea65..04c6eb9ff13b 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/__init__.py @@ -8,3 +8,8 @@ from ._microsoft_storage_sync import MicrosoftStorageSync __all__ = ['MicrosoftStorageSync'] + +# `._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-storagesync/azure/mgmt/storagesync/aio/_configuration.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/_configuration.py index 957ea3aa5c02..093beb85446c 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/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,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(MicrosoftStorageSyncConfiguration, 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(MicrosoftStorageSyncConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -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-storagesync/azure/mgmt/storagesync/aio/_microsoft_storage_sync.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/_microsoft_storage_sync.py index a1ccac388fd9..a7bbb44e815c 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/_microsoft_storage_sync.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/_microsoft_storage_sync.py @@ -6,40 +6,35 @@ # 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.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MicrosoftStorageSyncConfiguration +from .operations import CloudEndpointsOperations, MicrosoftStorageSyncOperationsMixin, OperationStatusOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, RegisteredServersOperations, ServerEndpointsOperations, StorageSyncServicesOperations, SyncGroupsOperations, WorkflowsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MicrosoftStorageSyncConfiguration -from .operations import Operations -from .operations import StorageSyncServicesOperations -from .operations import PrivateLinkResourcesOperations -from .operations import PrivateEndpointConnectionsOperations -from .operations import SyncGroupsOperations -from .operations import CloudEndpointsOperations -from .operations import ServerEndpointsOperations -from .operations import RegisteredServersOperations -from .operations import WorkflowsOperations -from .operations import OperationStatusOperations -from .. import models - - -class MicrosoftStorageSync(object): +class MicrosoftStorageSync(MicrosoftStorageSyncOperationsMixin): """Microsoft Storage Sync Service API. :ivar operations: Operations operations :vartype operations: azure.mgmt.storagesync.aio.operations.Operations :ivar storage_sync_services: StorageSyncServicesOperations operations - :vartype storage_sync_services: azure.mgmt.storagesync.aio.operations.StorageSyncServicesOperations + :vartype storage_sync_services: + azure.mgmt.storagesync.aio.operations.StorageSyncServicesOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: azure.mgmt.storagesync.aio.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: + azure.mgmt.storagesync.aio.operations.PrivateLinkResourcesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.storagesync.aio.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.storagesync.aio.operations.PrivateEndpointConnectionsOperations :ivar sync_groups: SyncGroupsOperations operations :vartype sync_groups: azure.mgmt.storagesync.aio.operations.SyncGroupsOperations :ivar cloud_endpoints: CloudEndpointsOperations operations @@ -56,47 +51,63 @@ class MicrosoftStorageSync(object): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :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 = MicrosoftStorageSyncConfiguration(credential, subscription_id, **kwargs) + self._config = MicrosoftStorageSyncConfiguration(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.storage_sync_services = StorageSyncServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sync_groups = SyncGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.cloud_endpoints = CloudEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_endpoints = ServerEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) + self.registered_servers = RegisteredServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.workflows = WorkflowsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.storage_sync_services = StorageSyncServicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.sync_groups = SyncGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.cloud_endpoints = CloudEndpointsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_endpoints = ServerEndpointsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.registered_servers = RegisteredServersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.workflows = WorkflowsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation_status = OperationStatusOperations( - self._client, self._config, self._serialize, self._deserialize) + 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-storagesync/azure/mgmt/storagesync/aio/_patch.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/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-storagesync/azure/mgmt/storagesync/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/__init__.py index 85ce9379c268..6498106a813e 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/__init__.py @@ -16,6 +16,7 @@ from ._registered_servers_operations import RegisteredServersOperations from ._workflows_operations import WorkflowsOperations from ._operation_status_operations import OperationStatusOperations +from ._microsoft_storage_sync_operations import MicrosoftStorageSyncOperationsMixin __all__ = [ 'Operations', @@ -28,4 +29,5 @@ 'RegisteredServersOperations', 'WorkflowsOperations', 'OperationStatusOperations', + 'MicrosoftStorageSyncOperationsMixin', ] diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_cloud_endpoints_operations.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_cloud_endpoints_operations.py index 29bbd5b3f0b7..38501a3b7c1a 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_cloud_endpoints_operations.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_cloud_endpoints_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._cloud_endpoints_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_sync_group_request, build_post_backup_request_initial, build_post_restore_request_initial, build_pre_backup_request_initial, build_pre_restore_request_initial, build_restoreheartbeat_request, build_trigger_change_detection_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -50,54 +55,44 @@ async def _create_initial( sync_group_name: str, cloud_endpoint_name: str, parameters: "_models.CloudEndpointCreateParameters", - **kwargs + **kwargs: Any ) -> Optional["_models.CloudEndpoint"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.CloudEndpoint"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CloudEndpointCreateParameters') - # 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') + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + cloud_endpoint_name=cloud_endpoint_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CloudEndpointCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('CloudEndpoint', pipeline_response) if response.status_code == 202: @@ -106,13 +101,17 @@ async def _create_initial( response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, @@ -120,7 +119,7 @@ async def begin_create( sync_group_name: str, cloud_endpoint_name: str, parameters: "_models.CloudEndpointCreateParameters", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.CloudEndpoint"]: """Create a new CloudEndpoint. @@ -136,15 +135,19 @@ async def begin_create( :type parameters: ~azure.mgmt.storagesync.models.CloudEndpointCreateParameters :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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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 CloudEndpoint 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 AsyncLROPoller that returns either CloudEndpoint or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storagesync.models.CloudEndpoint] - :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.CloudEndpoint"] lro_delay = kwargs.pop( 'polling_interval', @@ -158,33 +161,25 @@ async def begin_create( sync_group_name=sync_group_name, cloud_endpoint_name=cloud_endpoint_name, parameters=parameters, + 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_headers = {} response = pipeline_response.http_response response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('CloudEndpoint', pipeline_response) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, '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: @@ -196,15 +191,17 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, storage_sync_service_name: str, sync_group_name: str, cloud_endpoint_name: str, - **kwargs + **kwargs: Any ) -> "_models.CloudEndpoint": """Get a given CloudEndpoint. @@ -226,96 +223,79 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + cloud_endpoint_name=cloud_endpoint_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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('CloudEndpoint', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, storage_sync_service_name: str, sync_group_name: str, cloud_endpoint_name: str, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + cloud_endpoint_name=cloud_endpoint_name, + 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 if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if response.status_code == 202: response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) @@ -323,19 +303,22 @@ async def _delete_initial( response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, storage_sync_service_name: str, sync_group_name: str, cloud_endpoint_name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a given CloudEndpoint. @@ -349,15 +332,17 @@ async def begin_delete( :type cloud_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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', @@ -373,23 +358,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 = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, '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: @@ -401,14 +377,16 @@ 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.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}'} # type: ignore + @distributed_trace def list_by_sync_group( self, resource_group_name: str, storage_sync_service_name: str, sync_group_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.CloudEndpointArray"]: """Get a CloudEndpoint List. @@ -420,7 +398,8 @@ def list_by_sync_group( :type sync_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 CloudEndpointArray or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storagesync.models.CloudEndpointArray] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storagesync.models.CloudEndpointArray] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudEndpointArray"] @@ -428,37 +407,35 @@ def list_by_sync_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_sync_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sync_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + template_url=self.list_by_sync_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_sync_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_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('CloudEndpointArray', pipeline_response) + deserialized = self._deserialize("CloudEndpointArray", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -471,12 +448,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -489,65 +467,58 @@ async def _pre_backup_initial( sync_group_name: str, cloud_endpoint_name: str, parameters: "_models.BackupRequest", - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._pre_backup_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'BackupRequest') - # 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') + request = build_pre_backup_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + cloud_endpoint_name=cloud_endpoint_name, + content_type=content_type, + json=_json, + template_url=self._pre_backup_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BackupRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) _pre_backup_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/prebackup'} # type: ignore + + @distributed_trace_async async def begin_pre_backup( self, resource_group_name: str, @@ -555,7 +526,7 @@ async def begin_pre_backup( sync_group_name: str, cloud_endpoint_name: str, parameters: "_models.BackupRequest", - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Pre Backup a given CloudEndpoint. @@ -571,15 +542,18 @@ async def begin_pre_backup( :type parameters: ~azure.mgmt.storagesync.models.BackupRequest :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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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] + 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[None] lro_delay = kwargs.pop( 'polling_interval', @@ -593,26 +567,18 @@ async def begin_pre_backup( sync_group_name=sync_group_name, cloud_endpoint_name=cloud_endpoint_name, parameters=parameters, + 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): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, '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: @@ -624,6 +590,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_pre_backup.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/prebackup'} # type: ignore async def _post_backup_initial( @@ -633,68 +600,62 @@ async def _post_backup_initial( sync_group_name: str, cloud_endpoint_name: str, parameters: "_models.BackupRequest", - **kwargs + **kwargs: Any ) -> Optional["_models.PostBackupResponse"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PostBackupResponse"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._post_backup_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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') + _json = self._serialize.body(parameters, 'BackupRequest') + + request = build_post_backup_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + cloud_endpoint_name=cloud_endpoint_name, + content_type=content_type, + json=_json, + template_url=self._post_backup_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BackupRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('PostBackupResponse', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _post_backup_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/postbackup'} # type: ignore + + @distributed_trace_async async def begin_post_backup( self, resource_group_name: str, @@ -702,7 +663,7 @@ async def begin_post_backup( sync_group_name: str, cloud_endpoint_name: str, parameters: "_models.BackupRequest", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.PostBackupResponse"]: """Post Backup a given CloudEndpoint. @@ -718,15 +679,19 @@ async def begin_post_backup( :type parameters: ~azure.mgmt.storagesync.models.BackupRequest :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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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 PostBackupResponse 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 AsyncLROPoller that returns either PostBackupResponse or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storagesync.models.PostBackupResponse] - :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.PostBackupResponse"] lro_delay = kwargs.pop( 'polling_interval', @@ -740,12 +705,11 @@ async def begin_post_backup( sync_group_name=sync_group_name, cloud_endpoint_name=cloud_endpoint_name, parameters=parameters, + 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_headers = {} @@ -753,21 +717,14 @@ def get_long_running_output(pipeline_response): response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('PostBackupResponse', pipeline_response) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, '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: @@ -779,6 +736,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_post_backup.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/postbackup'} # type: ignore async def _pre_restore_initial( @@ -788,60 +746,52 @@ async def _pre_restore_initial( sync_group_name: str, cloud_endpoint_name: str, parameters: "_models.PreRestoreRequest", - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._pre_restore_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PreRestoreRequest') - # 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') + request = build_pre_restore_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + cloud_endpoint_name=cloud_endpoint_name, + content_type=content_type, + json=_json, + template_url=self._pre_restore_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PreRestoreRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) _pre_restore_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/prerestore'} # type: ignore + + @distributed_trace_async async def begin_pre_restore( self, resource_group_name: str, @@ -849,7 +799,7 @@ async def begin_pre_restore( sync_group_name: str, cloud_endpoint_name: str, parameters: "_models.PreRestoreRequest", - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Pre Restore a given CloudEndpoint. @@ -865,15 +815,18 @@ async def begin_pre_restore( :type parameters: ~azure.mgmt.storagesync.models.PreRestoreRequest :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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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] + 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[None] lro_delay = kwargs.pop( 'polling_interval', @@ -887,26 +840,18 @@ async def begin_pre_restore( sync_group_name=sync_group_name, cloud_endpoint_name=cloud_endpoint_name, parameters=parameters, + 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): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, '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: @@ -918,15 +863,17 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_pre_restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/prerestore'} # type: ignore + @distributed_trace_async async def restoreheartbeat( self, resource_group_name: str, storage_sync_service_name: str, sync_group_name: str, cloud_endpoint_name: str, - **kwargs + **kwargs: Any ) -> None: """Restore Heartbeat a given CloudEndpoint. @@ -948,46 +895,38 @@ async def restoreheartbeat( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.restoreheartbeat.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_restoreheartbeat_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + cloud_endpoint_name=cloud_endpoint_name, + template_url=self.restoreheartbeat.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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) restoreheartbeat.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/restoreheartbeat'} # type: ignore + async def _post_restore_initial( self, resource_group_name: str, @@ -995,60 +934,52 @@ async def _post_restore_initial( sync_group_name: str, cloud_endpoint_name: str, parameters: "_models.PostRestoreRequest", - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._post_restore_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PostRestoreRequest') - # 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') + request = build_post_restore_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + cloud_endpoint_name=cloud_endpoint_name, + content_type=content_type, + json=_json, + template_url=self._post_restore_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PostRestoreRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) _post_restore_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/postrestore'} # type: ignore + + @distributed_trace_async async def begin_post_restore( self, resource_group_name: str, @@ -1056,7 +987,7 @@ async def begin_post_restore( sync_group_name: str, cloud_endpoint_name: str, parameters: "_models.PostRestoreRequest", - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Post Restore a given CloudEndpoint. @@ -1072,15 +1003,18 @@ async def begin_post_restore( :type parameters: ~azure.mgmt.storagesync.models.PostRestoreRequest :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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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] + 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[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1094,26 +1028,18 @@ async def begin_post_restore( sync_group_name=sync_group_name, cloud_endpoint_name=cloud_endpoint_name, parameters=parameters, + 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): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, '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: @@ -1125,6 +1051,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_post_restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/postrestore'} # type: ignore async def _trigger_change_detection_initial( @@ -1134,60 +1061,52 @@ async def _trigger_change_detection_initial( sync_group_name: str, cloud_endpoint_name: str, parameters: "_models.TriggerChangeDetectionParameters", - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._trigger_change_detection_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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') + _json = self._serialize.body(parameters, 'TriggerChangeDetectionParameters') + + request = build_trigger_change_detection_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + cloud_endpoint_name=cloud_endpoint_name, + content_type=content_type, + json=_json, + template_url=self._trigger_change_detection_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TriggerChangeDetectionParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) _trigger_change_detection_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/triggerChangeDetection'} # type: ignore + + @distributed_trace_async async def begin_trigger_change_detection( self, resource_group_name: str, @@ -1195,7 +1114,7 @@ async def begin_trigger_change_detection( sync_group_name: str, cloud_endpoint_name: str, parameters: "_models.TriggerChangeDetectionParameters", - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Triggers detection of changes performed on Azure File share connected to the specified Azure File Sync Cloud Endpoint. @@ -1212,15 +1131,18 @@ async def begin_trigger_change_detection( :type parameters: ~azure.mgmt.storagesync.models.TriggerChangeDetectionParameters :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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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] + 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[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1234,26 +1156,18 @@ async def begin_trigger_change_detection( sync_group_name=sync_group_name, cloud_endpoint_name=cloud_endpoint_name, parameters=parameters, + 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): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, '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: @@ -1265,4 +1179,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_trigger_change_detection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/triggerChangeDetection'} # type: ignore diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_microsoft_storage_sync_operations.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_microsoft_storage_sync_operations.py new file mode 100644 index 000000000000..ab307c86bdfb --- /dev/null +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_microsoft_storage_sync_operations.py @@ -0,0 +1,81 @@ +# 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, 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 +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._microsoft_storage_sync_operations import build_location_operation_status_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class MicrosoftStorageSyncOperationsMixin: + + @distributed_trace_async + async def location_operation_status( + self, + location_name: str, + operation_id: str, + **kwargs: Any + ) -> "_models.LocationOperationStatus": + """Get Operation status. + + :param location_name: The desired region to obtain information from. + :type location_name: str + :param operation_id: operation Id. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocationOperationStatus, or the result of cls(response) + :rtype: ~azure.mgmt.storagesync.models.LocationOperationStatus + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationOperationStatus"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_location_operation_status_request( + subscription_id=self._config.subscription_id, + location_name=location_name, + operation_id=operation_id, + template_url=self.location_operation_status.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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) + response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + + deserialized = self._deserialize('LocationOperationStatus', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + location_operation_status.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.StorageSync/locations/{locationName}/operations/{operationId}'} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_operation_status_operations.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_operation_status_operations.py index 766180d609eb..255a424b7873 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_operation_status_operations.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_operation_status_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._operation_status_operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,13 +44,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, location_name: str, workflow_id: str, operation_id: str, - **kwargs + **kwargs: Any ) -> "_models.OperationStatus": """Get Operation status. @@ -68,44 +73,37 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'workflowId': self._serialize.url("workflow_id", workflow_id, '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, + resource_group_name=resource_group_name, + location_name=location_name, + workflow_id=workflow_id, + 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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('OperationStatus', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/locations/{locationName}/workflows/{workflowId}/operations/{operationId}'} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_operations.py index 05219f72b2bb..bcb8f8321e81 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/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,15 +46,18 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.OperationEntityListResult"]: """Lists all of the available Storage Sync Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationEntityListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storagesync.models.OperationEntityListResult] + :return: An iterator like instance of either OperationEntityListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storagesync.models.OperationEntityListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationEntityListResult"] @@ -57,30 +65,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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('OperationEntityListResult', pipeline_response) + deserialized = self._deserialize("OperationEntityListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +98,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_private_endpoint_connections_operations.py index fb7a4db315dc..9e250ff5865c 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_private_endpoint_connections_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._private_endpoint_connections_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_storage_sync_service_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,12 +48,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, storage_sync_service_name: str, private_endpoint_connection_name: str, - **kwargs + **kwargs: Any ) -> "_models.PrivateEndpointConnection": """Gets the specified private endpoint connection associated with the storage sync service. @@ -70,34 +76,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -106,58 +102,49 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + async def _create_initial( self, resource_group_name: str, storage_sync_service_name: str, private_endpoint_connection_name: str, properties: "_models.PrivateEndpointConnection", - **kwargs + **kwargs: Any ) -> Optional["_models.PrivateEndpointConnection"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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') + _json = self._serialize.body(properties, 'PrivateEndpointConnection') + + request = build_create_request_initial( + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'PrivateEndpointConnection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -167,20 +154,24 @@ async def _create_initial( response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, storage_sync_service_name: str, private_endpoint_connection_name: str, properties: "_models.PrivateEndpointConnection", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: """Update the state of specified private endpoint connection associated with the storage sync service. @@ -197,15 +188,20 @@ async def begin_create( :type properties: ~azure.mgmt.storagesync.models.PrivateEndpointConnection :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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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 PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storagesync.models.PrivateEndpointConnection] - :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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storagesync.models.PrivateEndpointConnection] + :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.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -218,28 +214,21 @@ async def begin_create( storage_sync_service_name=storage_sync_service_name, private_endpoint_connection_name=private_endpoint_connection_name, properties=properties, + 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('PrivateEndpointConnection', 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', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, '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: @@ -251,6 +240,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore async def _delete_initial( @@ -258,42 +248,31 @@ async def _delete_initial( resource_group_name: str, storage_sync_service_name: str, private_endpoint_connection_name: str, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + 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 if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: @@ -302,18 +281,21 @@ async def _delete_initial( response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, storage_sync_service_name: str, private_endpoint_connection_name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified private endpoint connection associated with the storage sync service. @@ -327,15 +309,17 @@ async def begin_delete( :type private_endpoint_connection_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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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', @@ -350,22 +334,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', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, '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: @@ -377,13 +353,15 @@ 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.StorageSync/storageSyncServices/{storageSyncServiceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + @distributed_trace def list_by_storage_sync_service( self, resource_group_name: str, storage_sync_service_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: """Get a PrivateEndpointConnection List. @@ -392,8 +370,10 @@ def list_by_storage_sync_service( :param storage_sync_service_name: Name of Storage Sync Service resource. :type storage_sync_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storagesync.models.PrivateEndpointConnectionListResult] + :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storagesync.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] @@ -401,36 +381,33 @@ def list_by_storage_sync_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_storage_sync_service.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_storage_sync_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + template_url=self.list_by_storage_sync_service.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_storage_sync_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_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('PrivateEndpointConnectionListResult', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -443,12 +420,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_private_link_resources_operations.py index fa7418f3bcdb..21463e2408c6 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_private_link_resources_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._private_link_resources_operations import build_list_by_storage_sync_service_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,11 +44,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_storage_sync_service( self, resource_group_name: str, storage_sync_service_name: str, - **kwargs + **kwargs: Any ) -> "_models.PrivateLinkResourceListResult": """Gets the private link resources that need to be created for a storage sync service. @@ -63,27 +68,17 @@ async def list_by_storage_sync_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.list_by_storage_sync_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_by_storage_sync_service_request( + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_storage_sync_service.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 @@ -97,4 +92,6 @@ async def list_by_storage_sync_service( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_storage_sync_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/privateLinkResources'} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_registered_servers_operations.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_registered_servers_operations.py index 22e0ef2f0868..1e4a5d0fef22 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_registered_servers_operations.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_registered_servers_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._registered_servers_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_storage_sync_service_request, build_trigger_rollover_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,11 +48,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_storage_sync_service( self, resource_group_name: str, storage_sync_service_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.RegisteredServerArray"]: """Get a given registered server list. @@ -56,8 +62,10 @@ def list_by_storage_sync_service( :param storage_sync_service_name: Name of Storage Sync Service resource. :type storage_sync_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegisteredServerArray or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storagesync.models.RegisteredServerArray] + :return: An iterator like instance of either RegisteredServerArray or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storagesync.models.RegisteredServerArray] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RegisteredServerArray"] @@ -65,36 +73,33 @@ def list_by_storage_sync_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_storage_sync_service.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_storage_sync_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + template_url=self.list_by_storage_sync_service.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_storage_sync_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_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('RegisteredServerArray', pipeline_response) + deserialized = self._deserialize("RegisteredServerArray", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -107,23 +112,25 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_storage_sync_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, storage_sync_service_name: str, server_id: str, - **kwargs + **kwargs: Any ) -> "_models.RegisteredServer": """Get a given registered server. @@ -143,100 +150,83 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'serverId': self._serialize.url("server_id", server_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, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + server_id=server_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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('RegisteredServer', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers/{serverId}'} # type: ignore + async def _create_initial( self, resource_group_name: str, storage_sync_service_name: str, server_id: str, parameters: "_models.RegisteredServerCreateParameters", - **kwargs + **kwargs: Any ) -> Optional["_models.RegisteredServer"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RegisteredServer"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'serverId': self._serialize.url("server_id", server_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegisteredServerCreateParameters') - # 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') + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + server_id=server_id, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegisteredServerCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('RegisteredServer', pipeline_response) if response.status_code == 202: @@ -244,20 +234,24 @@ async def _create_initial( response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers/{serverId}'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, storage_sync_service_name: str, server_id: str, parameters: "_models.RegisteredServerCreateParameters", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.RegisteredServer"]: """Add a new registered server. @@ -271,15 +265,19 @@ async def begin_create( :type parameters: ~azure.mgmt.storagesync.models.RegisteredServerCreateParameters :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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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 RegisteredServer 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 AsyncLROPoller that returns either RegisteredServer or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storagesync.models.RegisteredServer] - :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.RegisteredServer"] lro_delay = kwargs.pop( 'polling_interval', @@ -292,32 +290,25 @@ async def begin_create( storage_sync_service_name=storage_sync_service_name, server_id=server_id, parameters=parameters, + 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_headers = {} response = pipeline_response.http_response response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('RegisteredServer', pipeline_response) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'serverId': self._serialize.url("server_id", server_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: @@ -329,6 +320,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers/{serverId}'} # type: ignore async def _delete_initial( @@ -336,64 +328,57 @@ async def _delete_initial( resource_group_name: str, storage_sync_service_name: str, server_id: str, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'serverId': self._serialize.url("server_id", server_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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + server_id=server_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 if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers/{serverId}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, storage_sync_service_name: str, server_id: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the given registered server. @@ -405,15 +390,17 @@ async def begin_delete( :type server_id: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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', @@ -428,22 +415,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 = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'serverId': self._serialize.url("server_id", server_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: @@ -455,6 +434,7 @@ 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.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers/{serverId}'} # type: ignore async def _trigger_rollover_initial( @@ -463,70 +443,63 @@ async def _trigger_rollover_initial( storage_sync_service_name: str, server_id: str, parameters: "_models.TriggerRolloverRequest", - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._trigger_rollover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'serverId': self._serialize.url("server_id", server_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') + 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') + _json = self._serialize.body(parameters, 'TriggerRolloverRequest') + + request = build_trigger_rollover_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + server_id=server_id, + content_type=content_type, + json=_json, + template_url=self._trigger_rollover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TriggerRolloverRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) _trigger_rollover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers/{serverId}/triggerRollover'} # type: ignore + + @distributed_trace_async async def begin_trigger_rollover( self, resource_group_name: str, storage_sync_service_name: str, server_id: str, parameters: "_models.TriggerRolloverRequest", - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Triggers Server certificate rollover. @@ -540,15 +513,18 @@ async def begin_trigger_rollover( :type parameters: ~azure.mgmt.storagesync.models.TriggerRolloverRequest :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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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] + 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[None] lro_delay = kwargs.pop( 'polling_interval', @@ -561,25 +537,18 @@ async def begin_trigger_rollover( storage_sync_service_name=storage_sync_service_name, server_id=server_id, parameters=parameters, + 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): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'serverId': self._serialize.url("server_id", server_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: @@ -591,4 +560,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_trigger_rollover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers/{serverId}/triggerRollover'} # type: ignore diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_server_endpoints_operations.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_server_endpoints_operations.py index cd0a36ab3a29..06cdbfa62507 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_server_endpoints_operations.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_server_endpoints_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._server_endpoints_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_sync_group_request, build_recall_action_request_initial, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -50,54 +55,44 @@ async def _create_initial( sync_group_name: str, server_endpoint_name: str, parameters: "_models.ServerEndpointCreateParameters", - **kwargs + **kwargs: Any ) -> Optional["_models.ServerEndpoint"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerEndpoint"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'serverEndpointName': self._serialize.url("server_endpoint_name", server_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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') + _json = self._serialize.body(parameters, 'ServerEndpointCreateParameters') + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + server_endpoint_name=server_endpoint_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerEndpointCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('ServerEndpoint', pipeline_response) if response.status_code == 202: @@ -105,13 +100,17 @@ async def _create_initial( response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, @@ -119,7 +118,7 @@ async def begin_create( sync_group_name: str, server_endpoint_name: str, parameters: "_models.ServerEndpointCreateParameters", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.ServerEndpoint"]: """Create a new ServerEndpoint. @@ -135,15 +134,19 @@ async def begin_create( :type parameters: ~azure.mgmt.storagesync.models.ServerEndpointCreateParameters :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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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 ServerEndpoint 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 AsyncLROPoller that returns either ServerEndpoint or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storagesync.models.ServerEndpoint] - :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.ServerEndpoint"] lro_delay = kwargs.pop( 'polling_interval', @@ -157,33 +160,25 @@ async def begin_create( sync_group_name=sync_group_name, server_endpoint_name=server_endpoint_name, parameters=parameters, + 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_headers = {} response = pipeline_response.http_response response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('ServerEndpoint', pipeline_response) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'serverEndpointName': self._serialize.url("server_endpoint_name", server_endpoint_name, '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: @@ -195,6 +190,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}'} # type: ignore async def _update_initial( @@ -204,57 +200,47 @@ async def _update_initial( sync_group_name: str, server_endpoint_name: str, parameters: Optional["_models.ServerEndpointUpdateParameters"] = None, - **kwargs + **kwargs: Any ) -> Optional["_models.ServerEndpoint"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerEndpoint"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'serverEndpointName': self._serialize.url("server_endpoint_name", server_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: - body_content = self._serialize.body(parameters, 'ServerEndpointUpdateParameters') + _json = self._serialize.body(parameters, 'ServerEndpointUpdateParameters') 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_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + server_endpoint_name=server_endpoint_name, + content_type=content_type, + json=_json, + template_url=self._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 if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('ServerEndpoint', pipeline_response) if response.status_code == 202: @@ -262,13 +248,17 @@ async def _update_initial( response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -276,7 +266,7 @@ async def begin_update( sync_group_name: str, server_endpoint_name: str, parameters: Optional["_models.ServerEndpointUpdateParameters"] = None, - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.ServerEndpoint"]: """Patch a given ServerEndpoint. @@ -292,15 +282,19 @@ async def begin_update( :type parameters: ~azure.mgmt.storagesync.models.ServerEndpointUpdateParameters :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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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 ServerEndpoint 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 AsyncLROPoller that returns either ServerEndpoint or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storagesync.models.ServerEndpoint] - :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.ServerEndpoint"] lro_delay = kwargs.pop( 'polling_interval', @@ -314,33 +308,25 @@ async def begin_update( sync_group_name=sync_group_name, server_endpoint_name=server_endpoint_name, parameters=parameters, + 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_headers = {} response = pipeline_response.http_response response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('ServerEndpoint', pipeline_response) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'serverEndpointName': self._serialize.url("server_endpoint_name", server_endpoint_name, '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: @@ -352,15 +338,17 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, storage_sync_service_name: str, sync_group_name: str, server_endpoint_name: str, - **kwargs + **kwargs: Any ) -> "_models.ServerEndpoint": """Get a ServerEndpoint. @@ -382,114 +370,100 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'serverEndpointName': self._serialize.url("server_endpoint_name", server_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + server_endpoint_name=server_endpoint_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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('ServerEndpoint', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, storage_sync_service_name: str, sync_group_name: str, server_endpoint_name: str, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'serverEndpointName': self._serialize.url("server_endpoint_name", server_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + server_endpoint_name=server_endpoint_name, + 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 if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, storage_sync_service_name: str, sync_group_name: str, server_endpoint_name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a given ServerEndpoint. @@ -503,15 +477,17 @@ async def begin_delete( :type server_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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', @@ -527,23 +503,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 = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'serverEndpointName': self._serialize.url("server_endpoint_name", server_endpoint_name, '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: @@ -555,14 +522,16 @@ 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.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}'} # type: ignore + @distributed_trace def list_by_sync_group( self, resource_group_name: str, storage_sync_service_name: str, sync_group_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ServerEndpointArray"]: """Get a ServerEndpoint list. @@ -574,7 +543,8 @@ def list_by_sync_group( :type sync_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 ServerEndpointArray or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storagesync.models.ServerEndpointArray] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storagesync.models.ServerEndpointArray] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerEndpointArray"] @@ -582,37 +552,35 @@ def list_by_sync_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_sync_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sync_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + template_url=self.list_by_sync_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_sync_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_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('ServerEndpointArray', pipeline_response) + deserialized = self._deserialize("ServerEndpointArray", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -625,12 +593,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -643,64 +612,57 @@ async def _recall_action_initial( sync_group_name: str, server_endpoint_name: str, parameters: "_models.RecallActionParameters", - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._recall_action_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'serverEndpointName': self._serialize.url("server_endpoint_name", server_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RecallActionParameters') - # 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') + request = build_recall_action_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + server_endpoint_name=server_endpoint_name, + content_type=content_type, + json=_json, + template_url=self._recall_action_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RecallActionParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) _recall_action_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}/recallAction'} # type: ignore + + @distributed_trace_async async def begin_recall_action( self, resource_group_name: str, @@ -708,7 +670,7 @@ async def begin_recall_action( sync_group_name: str, server_endpoint_name: str, parameters: "_models.RecallActionParameters", - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Recall a server endpoint. @@ -724,15 +686,18 @@ async def begin_recall_action( :type parameters: ~azure.mgmt.storagesync.models.RecallActionParameters :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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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] + 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[None] lro_delay = kwargs.pop( 'polling_interval', @@ -746,26 +711,18 @@ async def begin_recall_action( sync_group_name=sync_group_name, server_endpoint_name=server_endpoint_name, parameters=parameters, + 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): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'serverEndpointName': self._serialize.url("server_endpoint_name", server_endpoint_name, '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: @@ -777,4 +734,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_recall_action.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}/recallAction'} # type: ignore diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_storage_sync_services_operations.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_storage_sync_services_operations.py index 2dbaf232cd01..a3c2acab6fb4 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_storage_sync_services_operations.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_storage_sync_services_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_sync_services_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,11 +48,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def check_name_availability( self, location_name: str, parameters: "_models.CheckNameAvailabilityParameters", - **kwargs + **kwargs: Any ) -> "_models.CheckNameAvailabilityResult": """Check the give namespace name availability. @@ -65,31 +71,21 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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') + _json = self._serialize.body(parameters, 'CheckNameAvailabilityParameters') + + request = build_check_name_availability_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailabilityParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -103,56 +99,47 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.StorageSync/locations/{locationName}/checkNameAvailability'} # type: ignore + async def _create_initial( self, resource_group_name: str, storage_sync_service_name: str, parameters: "_models.StorageSyncServiceCreateParameters", - **kwargs + **kwargs: Any ) -> Optional["_models.StorageSyncService"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageSyncService"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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') + _json = self._serialize.body(parameters, 'StorageSyncServiceCreateParameters') + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'StorageSyncServiceCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('StorageSyncService', pipeline_response) @@ -162,19 +149,23 @@ async def _create_initial( response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, storage_sync_service_name: str, parameters: "_models.StorageSyncServiceCreateParameters", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.StorageSyncService"]: """Create a new StorageSyncService. @@ -186,15 +177,19 @@ async def begin_create( :type parameters: ~azure.mgmt.storagesync.models.StorageSyncServiceCreateParameters :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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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 StorageSyncService 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 AsyncLROPoller that returns either StorageSyncService or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storagesync.models.StorageSyncService] - :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.StorageSyncService"] lro_delay = kwargs.pop( 'polling_interval', @@ -206,27 +201,21 @@ async def begin_create( resource_group_name=resource_group_name, storage_sync_service_name=storage_sync_service_name, parameters=parameters, + 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('StorageSyncService', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, '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: @@ -238,13 +227,15 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, storage_sync_service_name: str, - **kwargs + **kwargs: Any ) -> "_models.StorageSyncService": """Get a given StorageSyncService. @@ -262,100 +253,83 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('StorageSyncService', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}'} # type: ignore + async def _update_initial( self, resource_group_name: str, storage_sync_service_name: str, parameters: Optional["_models.StorageSyncServiceUpdateParameters"] = None, - **kwargs + **kwargs: Any ) -> Optional["_models.StorageSyncService"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageSyncService"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: - body_content = self._serialize.body(parameters, 'StorageSyncServiceUpdateParameters') + _json = self._serialize.body(parameters, 'StorageSyncServiceUpdateParameters') 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_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + content_type=content_type, + json=_json, + template_url=self._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 if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('StorageSyncService', pipeline_response) if response.status_code == 202: @@ -364,19 +338,23 @@ async def _update_initial( response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, storage_sync_service_name: str, parameters: Optional["_models.StorageSyncServiceUpdateParameters"] = None, - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.StorageSyncService"]: """Patch a given StorageSyncService. @@ -388,15 +366,19 @@ async def begin_update( :type parameters: ~azure.mgmt.storagesync.models.StorageSyncServiceUpdateParameters :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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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 StorageSyncService 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 AsyncLROPoller that returns either StorageSyncService or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storagesync.models.StorageSyncService] - :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.StorageSyncService"] lro_delay = kwargs.pop( 'polling_interval', @@ -408,31 +390,25 @@ async def begin_update( resource_group_name=resource_group_name, storage_sync_service_name=storage_sync_service_name, parameters=parameters, + 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_headers = {} response = pipeline_response.http_response response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('StorageSyncService', pipeline_response) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, '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: @@ -444,52 +420,43 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}'} # type: ignore async def _delete_initial( self, resource_group_name: str, storage_sync_service_name: str, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + 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 if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if response.status_code == 202: response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) @@ -497,17 +464,20 @@ async def _delete_initial( response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, storage_sync_service_name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a given StorageSyncService. @@ -517,15 +487,17 @@ async def begin_delete( :type storage_sync_service_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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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', @@ -539,21 +511,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 = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, '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: @@ -565,20 +530,24 @@ 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.StorageSync/storageSyncServices/{storageSyncServiceName}'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.StorageSyncServiceArray"]: """Get a StorageSyncService list by Resource group name. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSyncServiceArray or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storagesync.models.StorageSyncServiceArray] + :return: An iterator like instance of either StorageSyncServiceArray or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storagesync.models.StorageSyncServiceArray] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSyncServiceArray"] @@ -586,35 +555,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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 = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + 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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_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('StorageSyncServiceArray', pipeline_response) + deserialized = self._deserialize("StorageSyncServiceArray", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -627,26 +592,30 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.StorageSyncServiceArray"]: """Get a StorageSyncService list by subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSyncServiceArray or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storagesync.models.StorageSyncServiceArray] + :return: An iterator like instance of either StorageSyncServiceArray or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storagesync.models.StorageSyncServiceArray] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSyncServiceArray"] @@ -654,34 +623,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.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_subscription_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('StorageSyncServiceArray', pipeline_response) + deserialized = self._deserialize("StorageSyncServiceArray", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -694,12 +658,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_sync_groups_operations.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_sync_groups_operations.py index 34246f413920..061221542caf 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_sync_groups_operations.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_sync_groups_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._sync_groups_operations import build_create_request, build_delete_request, build_get_request, build_list_by_storage_sync_service_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,11 +46,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_storage_sync_service( self, resource_group_name: str, storage_sync_service_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.SyncGroupArray"]: """Get a SyncGroup List. @@ -63,36 +69,33 @@ def list_by_storage_sync_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_storage_sync_service.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_storage_sync_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + template_url=self.list_by_storage_sync_service.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_storage_sync_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_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('SyncGroupArray', pipeline_response) + deserialized = self._deserialize("SyncGroupArray", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,24 +108,26 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_storage_sync_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups'} # type: ignore + @distributed_trace_async async def create( self, resource_group_name: str, storage_sync_service_name: str, sync_group_name: str, parameters: "_models.SyncGroupCreateParameters", - **kwargs + **kwargs: Any ) -> "_models.SyncGroup": """Create a new SyncGroup. @@ -144,58 +149,52 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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') + _json = self._serialize.body(parameters, 'SyncGroupCreateParameters') + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SyncGroupCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('SyncGroup', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, storage_sync_service_name: str, sync_group_name: str, - **kwargs + **kwargs: Any ) -> "_models.SyncGroup": """Get a given SyncGroup. @@ -215,53 +214,47 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('SyncGroup', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, storage_sync_service_name: str, sync_group_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete a given SyncGroup. @@ -281,42 +274,34 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + template_url=self.delete.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 if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}'} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_workflows_operations.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_workflows_operations.py index 556af5ef9f30..0fb297a1dc38 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_workflows_operations.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/aio/operations/_workflows_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._workflows_operations import build_abort_request, build_get_request, build_list_by_storage_sync_service_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,11 +46,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_storage_sync_service( self, resource_group_name: str, storage_sync_service_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.WorkflowArray"]: """Get a Workflow List. @@ -63,36 +69,33 @@ def list_by_storage_sync_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_storage_sync_service.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_storage_sync_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + template_url=self.list_by_storage_sync_service.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_storage_sync_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_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('WorkflowArray', pipeline_response) + deserialized = self._deserialize("WorkflowArray", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,23 +108,25 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_storage_sync_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/workflows'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, storage_sync_service_name: str, workflow_id: str, - **kwargs + **kwargs: Any ) -> "_models.Workflow": """Get Workflows resource. @@ -141,53 +146,47 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'workflowId': self._serialize.url("workflow_id", workflow_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, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + workflow_id=workflow_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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('Workflow', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/workflows/{workflowId}'} # type: ignore + + @distributed_trace_async async def abort( self, resource_group_name: str, storage_sync_service_name: str, workflow_id: str, - **kwargs + **kwargs: Any ) -> None: """Abort the given workflow. @@ -207,41 +206,33 @@ async def abort( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.abort.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'workflowId': self._serialize.url("workflow_id", workflow_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_abort_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + workflow_id=workflow_id, + template_url=self.abort.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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) abort.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/workflows/{workflowId}/abort'} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/models/__init__.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/models/__init__.py index 78d2687ac751..fffe8324f5fa 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/models/__init__.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/models/__init__.py @@ -6,148 +6,87 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import BackupRequest - from ._models_py3 import CheckNameAvailabilityParameters - from ._models_py3 import CheckNameAvailabilityResult - from ._models_py3 import CloudEndpoint - from ._models_py3 import CloudEndpointArray - from ._models_py3 import CloudEndpointCreateParameters - from ._models_py3 import CloudTieringCachePerformance - from ._models_py3 import CloudTieringDatePolicyStatus - from ._models_py3 import CloudTieringFilesNotTiering - from ._models_py3 import CloudTieringSpaceSavings - from ._models_py3 import CloudTieringVolumeFreeSpacePolicyStatus - from ._models_py3 import FilesNotTieringError - from ._models_py3 import OperationDisplayInfo - from ._models_py3 import OperationDisplayResource - from ._models_py3 import OperationEntity - from ._models_py3 import OperationEntityListResult - from ._models_py3 import OperationProperties - from ._models_py3 import OperationResourceMetricSpecification - from ._models_py3 import OperationResourceMetricSpecificationDimension - from ._models_py3 import OperationResourceServiceSpecification - from ._models_py3 import OperationStatus - from ._models_py3 import PostBackupResponse - from ._models_py3 import PostRestoreRequest - from ._models_py3 import PreRestoreRequest - from ._models_py3 import PrivateEndpoint - from ._models_py3 import PrivateEndpointConnection - from ._models_py3 import PrivateEndpointConnectionListResult - from ._models_py3 import PrivateLinkResource - from ._models_py3 import PrivateLinkResourceListResult - from ._models_py3 import PrivateLinkServiceConnectionState - from ._models_py3 import ProxyResource - from ._models_py3 import RecallActionParameters - from ._models_py3 import RegisteredServer - from ._models_py3 import RegisteredServerArray - from ._models_py3 import RegisteredServerCreateParameters - from ._models_py3 import Resource - from ._models_py3 import ResourcesMoveInfo - from ._models_py3 import RestoreFileSpec - from ._models_py3 import ServerEndpoint - from ._models_py3 import ServerEndpointArray - from ._models_py3 import ServerEndpointBackgroundDataDownloadActivity - from ._models_py3 import ServerEndpointCloudTieringStatus - from ._models_py3 import ServerEndpointCreateParameters - from ._models_py3 import ServerEndpointFilesNotSyncingError - from ._models_py3 import ServerEndpointRecallError - from ._models_py3 import ServerEndpointRecallStatus - from ._models_py3 import ServerEndpointSyncActivityStatus - from ._models_py3 import ServerEndpointSyncSessionStatus - from ._models_py3 import ServerEndpointSyncStatus - from ._models_py3 import ServerEndpointUpdateParameters - from ._models_py3 import StorageSyncApiError - from ._models_py3 import StorageSyncError - from ._models_py3 import StorageSyncErrorDetails - from ._models_py3 import StorageSyncInnerErrorDetails - from ._models_py3 import StorageSyncService - from ._models_py3 import StorageSyncServiceArray - from ._models_py3 import StorageSyncServiceCreateParameters - from ._models_py3 import StorageSyncServiceUpdateParameters - from ._models_py3 import SubscriptionState - from ._models_py3 import SyncGroup - from ._models_py3 import SyncGroupArray - from ._models_py3 import SyncGroupCreateParameters - from ._models_py3 import TrackedResource - from ._models_py3 import TriggerChangeDetectionParameters - from ._models_py3 import TriggerRolloverRequest - from ._models_py3 import Workflow - from ._models_py3 import WorkflowArray -except (SyntaxError, ImportError): - from ._models import BackupRequest # type: ignore - from ._models import CheckNameAvailabilityParameters # type: ignore - from ._models import CheckNameAvailabilityResult # type: ignore - from ._models import CloudEndpoint # type: ignore - from ._models import CloudEndpointArray # type: ignore - from ._models import CloudEndpointCreateParameters # type: ignore - from ._models import CloudTieringCachePerformance # type: ignore - from ._models import CloudTieringDatePolicyStatus # type: ignore - from ._models import CloudTieringFilesNotTiering # type: ignore - from ._models import CloudTieringSpaceSavings # type: ignore - from ._models import CloudTieringVolumeFreeSpacePolicyStatus # type: ignore - from ._models import FilesNotTieringError # type: ignore - from ._models import OperationDisplayInfo # type: ignore - from ._models import OperationDisplayResource # type: ignore - from ._models import OperationEntity # type: ignore - from ._models import OperationEntityListResult # type: ignore - from ._models import OperationProperties # type: ignore - from ._models import OperationResourceMetricSpecification # type: ignore - from ._models import OperationResourceMetricSpecificationDimension # type: ignore - from ._models import OperationResourceServiceSpecification # type: ignore - from ._models import OperationStatus # type: ignore - from ._models import PostBackupResponse # type: ignore - from ._models import PostRestoreRequest # type: ignore - from ._models import PreRestoreRequest # type: ignore - from ._models import PrivateEndpoint # type: ignore - from ._models import PrivateEndpointConnection # type: ignore - from ._models import PrivateEndpointConnectionListResult # type: ignore - from ._models import PrivateLinkResource # type: ignore - from ._models import PrivateLinkResourceListResult # type: ignore - from ._models import PrivateLinkServiceConnectionState # type: ignore - from ._models import ProxyResource # type: ignore - from ._models import RecallActionParameters # type: ignore - from ._models import RegisteredServer # type: ignore - from ._models import RegisteredServerArray # type: ignore - from ._models import RegisteredServerCreateParameters # type: ignore - from ._models import Resource # type: ignore - from ._models import ResourcesMoveInfo # type: ignore - from ._models import RestoreFileSpec # type: ignore - from ._models import ServerEndpoint # type: ignore - from ._models import ServerEndpointArray # type: ignore - from ._models import ServerEndpointBackgroundDataDownloadActivity # type: ignore - from ._models import ServerEndpointCloudTieringStatus # type: ignore - from ._models import ServerEndpointCreateParameters # type: ignore - from ._models import ServerEndpointFilesNotSyncingError # type: ignore - from ._models import ServerEndpointRecallError # type: ignore - from ._models import ServerEndpointRecallStatus # type: ignore - from ._models import ServerEndpointSyncActivityStatus # type: ignore - from ._models import ServerEndpointSyncSessionStatus # type: ignore - from ._models import ServerEndpointSyncStatus # type: ignore - from ._models import ServerEndpointUpdateParameters # type: ignore - from ._models import StorageSyncApiError # type: ignore - from ._models import StorageSyncError # type: ignore - from ._models import StorageSyncErrorDetails # type: ignore - from ._models import StorageSyncInnerErrorDetails # type: ignore - from ._models import StorageSyncService # type: ignore - from ._models import StorageSyncServiceArray # type: ignore - from ._models import StorageSyncServiceCreateParameters # type: ignore - from ._models import StorageSyncServiceUpdateParameters # type: ignore - from ._models import SubscriptionState # type: ignore - from ._models import SyncGroup # type: ignore - from ._models import SyncGroupArray # type: ignore - from ._models import SyncGroupCreateParameters # type: ignore - from ._models import TrackedResource # type: ignore - from ._models import TriggerChangeDetectionParameters # type: ignore - from ._models import TriggerRolloverRequest # type: ignore - from ._models import Workflow # type: ignore - from ._models import WorkflowArray # type: ignore +from ._models_py3 import BackupRequest +from ._models_py3 import CheckNameAvailabilityParameters +from ._models_py3 import CheckNameAvailabilityResult +from ._models_py3 import CloudEndpoint +from ._models_py3 import CloudEndpointArray +from ._models_py3 import CloudEndpointChangeEnumerationActivity +from ._models_py3 import CloudEndpointChangeEnumerationStatus +from ._models_py3 import CloudEndpointCreateParameters +from ._models_py3 import CloudEndpointLastChangeEnumerationStatus +from ._models_py3 import CloudTieringCachePerformance +from ._models_py3 import CloudTieringDatePolicyStatus +from ._models_py3 import CloudTieringFilesNotTiering +from ._models_py3 import CloudTieringSpaceSavings +from ._models_py3 import CloudTieringVolumeFreeSpacePolicyStatus +from ._models_py3 import FilesNotTieringError +from ._models_py3 import LocationOperationStatus +from ._models_py3 import OperationDisplayInfo +from ._models_py3 import OperationDisplayResource +from ._models_py3 import OperationEntity +from ._models_py3 import OperationEntityListResult +from ._models_py3 import OperationProperties +from ._models_py3 import OperationResourceMetricSpecification +from ._models_py3 import OperationResourceMetricSpecificationDimension +from ._models_py3 import OperationResourceServiceSpecification +from ._models_py3 import OperationStatus +from ._models_py3 import PostBackupResponse +from ._models_py3 import PostRestoreRequest +from ._models_py3 import PreRestoreRequest +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionListResult +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourceListResult +from ._models_py3 import PrivateLinkServiceConnectionState +from ._models_py3 import ProxyResource +from ._models_py3 import RecallActionParameters +from ._models_py3 import RegisteredServer +from ._models_py3 import RegisteredServerArray +from ._models_py3 import RegisteredServerCreateParameters +from ._models_py3 import Resource +from ._models_py3 import ResourcesMoveInfo +from ._models_py3 import RestoreFileSpec +from ._models_py3 import ServerEndpoint +from ._models_py3 import ServerEndpointArray +from ._models_py3 import ServerEndpointBackgroundDataDownloadActivity +from ._models_py3 import ServerEndpointCloudTieringStatus +from ._models_py3 import ServerEndpointCreateParameters +from ._models_py3 import ServerEndpointFilesNotSyncingError +from ._models_py3 import ServerEndpointRecallError +from ._models_py3 import ServerEndpointRecallStatus +from ._models_py3 import ServerEndpointSyncActivityStatus +from ._models_py3 import ServerEndpointSyncSessionStatus +from ._models_py3 import ServerEndpointSyncStatus +from ._models_py3 import ServerEndpointUpdateParameters +from ._models_py3 import StorageSyncApiError +from ._models_py3 import StorageSyncError +from ._models_py3 import StorageSyncErrorDetails +from ._models_py3 import StorageSyncInnerErrorDetails +from ._models_py3 import StorageSyncService +from ._models_py3 import StorageSyncServiceArray +from ._models_py3 import StorageSyncServiceCreateParameters +from ._models_py3 import StorageSyncServiceUpdateParameters +from ._models_py3 import SubscriptionState +from ._models_py3 import SyncGroup +from ._models_py3 import SyncGroupArray +from ._models_py3 import SyncGroupCreateParameters +from ._models_py3 import TrackedResource +from ._models_py3 import TriggerChangeDetectionParameters +from ._models_py3 import TriggerRolloverRequest +from ._models_py3 import Workflow +from ._models_py3 import WorkflowArray + from ._microsoft_storage_sync_enums import ( ChangeDetectionMode, + CloudEndpointChangeEnumerationActivityState, + CloudEndpointChangeEnumerationTotalCountsState, FeatureStatus, IncomingTrafficPolicy, InitialDownloadPolicy, + InitialUploadPolicy, LocalCacheMode, NameAvailabilityReason, OperationDirection, @@ -169,13 +108,17 @@ 'CheckNameAvailabilityResult', 'CloudEndpoint', 'CloudEndpointArray', + 'CloudEndpointChangeEnumerationActivity', + 'CloudEndpointChangeEnumerationStatus', 'CloudEndpointCreateParameters', + 'CloudEndpointLastChangeEnumerationStatus', 'CloudTieringCachePerformance', 'CloudTieringDatePolicyStatus', 'CloudTieringFilesNotTiering', 'CloudTieringSpaceSavings', 'CloudTieringVolumeFreeSpacePolicyStatus', 'FilesNotTieringError', + 'LocationOperationStatus', 'OperationDisplayInfo', 'OperationDisplayResource', 'OperationEntity', @@ -232,9 +175,12 @@ 'Workflow', 'WorkflowArray', 'ChangeDetectionMode', + 'CloudEndpointChangeEnumerationActivityState', + 'CloudEndpointChangeEnumerationTotalCountsState', 'FeatureStatus', 'IncomingTrafficPolicy', 'InitialDownloadPolicy', + 'InitialUploadPolicy', 'LocalCacheMode', 'NameAvailabilityReason', 'OperationDirection', diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/models/_microsoft_storage_sync_enums.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/models/_microsoft_storage_sync_enums.py index 3a002f71150f..7f29392aafba 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/models/_microsoft_storage_sync_enums.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/models/_microsoft_storage_sync_enums.py @@ -6,48 +6,47 @@ # 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 ChangeDetectionMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ChangeDetectionMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Change Detection Mode. Applies to a directory specified in directoryPath parameter. """ DEFAULT = "Default" RECURSIVE = "Recursive" -class FeatureStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CloudEndpointChangeEnumerationActivityState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """State of change enumeration activity + """ + + INITIAL_ENUMERATION_IN_PROGRESS = "InitialEnumerationInProgress" + ENUMERATION_IN_PROGRESS = "EnumerationInProgress" + +class CloudEndpointChangeEnumerationTotalCountsState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """State of the total counts of change enumeration activity + """ + + CALCULATING = "Calculating" + FINAL = "Final" + +class FeatureStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of the Feature Status """ ON = "on" OFF = "off" -class IncomingTrafficPolicy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IncomingTrafficPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of the Incoming Traffic Policy """ ALLOW_ALL_TRAFFIC = "AllowAllTraffic" ALLOW_VIRTUAL_NETWORKS_ONLY = "AllowVirtualNetworksOnly" -class InitialDownloadPolicy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class InitialDownloadPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Policy for how namespace and files are recalled during FastDr """ @@ -55,15 +54,22 @@ class InitialDownloadPolicy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) NAMESPACE_THEN_MODIFIED_FILES = "NamespaceThenModifiedFiles" AVOID_TIERED_FILES = "AvoidTieredFiles" -class LocalCacheMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Policy for enabling follow-the-sun business models: link local cache to cloud behavior to pre- - populate before local access. +class InitialUploadPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Policy for how the initial upload sync session is performed. + """ + + SERVER_AUTHORITATIVE = "ServerAuthoritative" + MERGE = "Merge" + +class LocalCacheMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Policy for enabling follow-the-sun business models: link local cache to cloud behavior to + pre-populate before local access. """ DOWNLOAD_NEW_AND_MODIFIED_FILES = "DownloadNewAndModifiedFiles" UPDATE_LOCALLY_CACHED_FILES = "UpdateLocallyCachedFiles" -class NameAvailabilityReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NameAvailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Gets the reason that a Storage Sync Service name could not be used. The Reason element is only returned if NameAvailable is false. """ @@ -71,7 +77,7 @@ class NameAvailabilityReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum) INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class OperationDirection(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OperationDirection(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of the Operation Direction """ @@ -79,7 +85,7 @@ class OperationDirection(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UNDO = "undo" CANCEL = "cancel" -class PrivateEndpointConnectionProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The current provisioning state. """ @@ -88,7 +94,7 @@ class PrivateEndpointConnectionProvisioningState(with_metaclass(_CaseInsensitive DELETING = "Deleting" FAILED = "Failed" -class PrivateEndpointServiceConnectionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The private endpoint connection status. """ @@ -96,7 +102,7 @@ class PrivateEndpointServiceConnectionStatus(with_metaclass(_CaseInsensitiveEnum APPROVED = "Approved" REJECTED = "Rejected" -class ProgressType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProgressType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of the ProgressType """ @@ -106,7 +112,7 @@ class ProgressType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UPLOAD = "upload" RECALL = "recall" -class Reason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """State of Azure Subscription """ @@ -116,7 +122,7 @@ class Reason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SUSPENDED = "Suspended" DELETED = "Deleted" -class RegisteredServerAgentVersionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RegisteredServerAgentVersionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of the registered server agent version status """ @@ -125,7 +131,7 @@ class RegisteredServerAgentVersionStatus(with_metaclass(_CaseInsensitiveEnumMeta EXPIRED = "Expired" BLOCKED = "Blocked" -class ServerEndpointHealthState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ServerEndpointHealthState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of the server endpoint health state """ @@ -133,7 +139,7 @@ class ServerEndpointHealthState(with_metaclass(_CaseInsensitiveEnumMeta, str, En HEALTHY = "Healthy" ERROR = "Error" -class ServerEndpointOfflineDataTransferState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ServerEndpointOfflineDataTransferState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of the Health state """ @@ -142,7 +148,7 @@ class ServerEndpointOfflineDataTransferState(with_metaclass(_CaseInsensitiveEnum NOT_RUNNING = "NotRunning" COMPLETE = "Complete" -class ServerEndpointSyncActivityState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ServerEndpointSyncActivityState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of the sync activity state """ @@ -150,7 +156,7 @@ class ServerEndpointSyncActivityState(with_metaclass(_CaseInsensitiveEnumMeta, s DOWNLOAD = "Download" UPLOAD_AND_DOWNLOAD = "UploadAndDownload" -class ServerEndpointSyncMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ServerEndpointSyncMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Sync mode for the server endpoint. """ @@ -160,7 +166,7 @@ class ServerEndpointSyncMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum) SNAPSHOT_UPLOAD = "SnapshotUpload" INITIAL_FULL_DOWNLOAD = "InitialFullDownload" -class WorkflowStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class WorkflowStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of the Workflow Status """ diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/models/_models.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/models/_models.py deleted file mode 100644 index 0dbfd9dba1aa..000000000000 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/models/_models.py +++ /dev/null @@ -1,2733 +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. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class BackupRequest(msrest.serialization.Model): - """Backup request. - - :param azure_file_share: Azure File Share. - :type azure_file_share: str - """ - - _attribute_map = { - 'azure_file_share': {'key': 'azureFileShare', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BackupRequest, self).__init__(**kwargs) - self.azure_file_share = kwargs.get('azure_file_share', None) - - -class CheckNameAvailabilityParameters(msrest.serialization.Model): - """Parameters for a check name availability request. - - 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 name: Required. The name to check for availability. - :type name: str - :ivar type: Required. The resource type. Must be set to - Microsoft.StorageSync/storageSyncServices. Default value: - "Microsoft.StorageSync/storageSyncServices". - :vartype type: str - """ - - _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - type = "Microsoft.StorageSync/storageSyncServices" - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailabilityParameters, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class CheckNameAvailabilityResult(msrest.serialization.Model): - """The CheckNameAvailability operation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name_available: Gets a boolean value that indicates whether the name is available for you - to use. If true, the name is available. If false, the name has already been taken or invalid - and cannot be used. - :vartype name_available: bool - :ivar reason: Gets the reason that a Storage Sync Service name could not be used. The Reason - element is only returned if NameAvailable is false. Possible values include: "Invalid", - "AlreadyExists". - :vartype reason: str or ~azure.mgmt.storagesync.models.NameAvailabilityReason - :ivar message: Gets an error message explaining the Reason value in more detail. - :vartype message: str - """ - - _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailabilityResult, self).__init__(**kwargs) - self.name_available = None - self.reason = None - self.message = None - - -class Resource(msrest.serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProxyResource, self).__init__(**kwargs) - - -class CloudEndpoint(ProxyResource): - """Cloud Endpoint object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param storage_account_resource_id: Storage Account Resource Id. - :type storage_account_resource_id: str - :param azure_file_share_name: Azure file share name. - :type azure_file_share_name: str - :param storage_account_tenant_id: Storage Account Tenant Id. - :type storage_account_tenant_id: str - :param partnership_id: Partnership Id. - :type partnership_id: str - :param friendly_name: Friendly Name. - :type friendly_name: str - :ivar backup_enabled: Backup Enabled. - :vartype backup_enabled: str - :param provisioning_state: CloudEndpoint Provisioning State. - :type provisioning_state: str - :param last_workflow_id: CloudEndpoint lastWorkflowId. - :type last_workflow_id: str - :param last_operation_name: Resource Last Operation Name. - :type last_operation_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'backup_enabled': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'storage_account_resource_id': {'key': 'properties.storageAccountResourceId', 'type': 'str'}, - 'azure_file_share_name': {'key': 'properties.azureFileShareName', 'type': 'str'}, - 'storage_account_tenant_id': {'key': 'properties.storageAccountTenantId', 'type': 'str'}, - 'partnership_id': {'key': 'properties.partnershipId', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'backup_enabled': {'key': 'properties.backupEnabled', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'last_workflow_id': {'key': 'properties.lastWorkflowId', 'type': 'str'}, - 'last_operation_name': {'key': 'properties.lastOperationName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudEndpoint, self).__init__(**kwargs) - self.storage_account_resource_id = kwargs.get('storage_account_resource_id', None) - self.azure_file_share_name = kwargs.get('azure_file_share_name', None) - self.storage_account_tenant_id = kwargs.get('storage_account_tenant_id', None) - self.partnership_id = kwargs.get('partnership_id', None) - self.friendly_name = kwargs.get('friendly_name', None) - self.backup_enabled = None - self.provisioning_state = kwargs.get('provisioning_state', None) - self.last_workflow_id = kwargs.get('last_workflow_id', None) - self.last_operation_name = kwargs.get('last_operation_name', None) - - -class CloudEndpointArray(msrest.serialization.Model): - """Array of CloudEndpoint. - - :param value: Collection of CloudEndpoint. - :type value: list[~azure.mgmt.storagesync.models.CloudEndpoint] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[CloudEndpoint]'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudEndpointArray, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class CloudEndpointCreateParameters(ProxyResource): - """The parameters used when creating a cloud endpoint. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param storage_account_resource_id: Storage Account Resource Id. - :type storage_account_resource_id: str - :param azure_file_share_name: Azure file share name. - :type azure_file_share_name: str - :param storage_account_tenant_id: Storage Account Tenant Id. - :type storage_account_tenant_id: str - :param friendly_name: Friendly Name. - :type friendly_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'storage_account_resource_id': {'key': 'properties.storageAccountResourceId', 'type': 'str'}, - 'azure_file_share_name': {'key': 'properties.azureFileShareName', 'type': 'str'}, - 'storage_account_tenant_id': {'key': 'properties.storageAccountTenantId', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudEndpointCreateParameters, self).__init__(**kwargs) - self.storage_account_resource_id = kwargs.get('storage_account_resource_id', None) - self.azure_file_share_name = kwargs.get('azure_file_share_name', None) - self.storage_account_tenant_id = kwargs.get('storage_account_tenant_id', None) - self.friendly_name = kwargs.get('friendly_name', None) - - -class CloudTieringCachePerformance(msrest.serialization.Model): - """Server endpoint cloud tiering status object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar last_updated_timestamp: Last updated timestamp. - :vartype last_updated_timestamp: ~datetime.datetime - :ivar cache_hit_bytes: Count of bytes that were served from the local server. - :vartype cache_hit_bytes: long - :ivar cache_miss_bytes: Count of bytes that were served from the cloud. - :vartype cache_miss_bytes: long - :ivar cache_hit_bytes_percent: Percentage of total bytes (hit + miss) that were served from the - local server. - :vartype cache_hit_bytes_percent: int - """ - - _validation = { - 'last_updated_timestamp': {'readonly': True}, - 'cache_hit_bytes': {'readonly': True, 'minimum': 0}, - 'cache_miss_bytes': {'readonly': True, 'minimum': 0}, - 'cache_hit_bytes_percent': {'readonly': True, 'maximum': 100, 'minimum': 0}, - } - - _attribute_map = { - 'last_updated_timestamp': {'key': 'lastUpdatedTimestamp', 'type': 'iso-8601'}, - 'cache_hit_bytes': {'key': 'cacheHitBytes', 'type': 'long'}, - 'cache_miss_bytes': {'key': 'cacheMissBytes', 'type': 'long'}, - 'cache_hit_bytes_percent': {'key': 'cacheHitBytesPercent', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudTieringCachePerformance, self).__init__(**kwargs) - self.last_updated_timestamp = None - self.cache_hit_bytes = None - self.cache_miss_bytes = None - self.cache_hit_bytes_percent = None - - -class CloudTieringDatePolicyStatus(msrest.serialization.Model): - """Status of the date policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar last_updated_timestamp: Last updated timestamp. - :vartype last_updated_timestamp: ~datetime.datetime - :ivar tiered_files_most_recent_access_timestamp: Most recent access time of tiered files. - :vartype tiered_files_most_recent_access_timestamp: ~datetime.datetime - """ - - _validation = { - 'last_updated_timestamp': {'readonly': True}, - 'tiered_files_most_recent_access_timestamp': {'readonly': True}, - } - - _attribute_map = { - 'last_updated_timestamp': {'key': 'lastUpdatedTimestamp', 'type': 'iso-8601'}, - 'tiered_files_most_recent_access_timestamp': {'key': 'tieredFilesMostRecentAccessTimestamp', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudTieringDatePolicyStatus, self).__init__(**kwargs) - self.last_updated_timestamp = None - self.tiered_files_most_recent_access_timestamp = None - - -class CloudTieringFilesNotTiering(msrest.serialization.Model): - """Server endpoint cloud tiering status object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar last_updated_timestamp: Last updated timestamp. - :vartype last_updated_timestamp: ~datetime.datetime - :ivar total_file_count: Last cloud tiering result (HResult). - :vartype total_file_count: long - :ivar errors: Array of tiering errors. - :vartype errors: list[~azure.mgmt.storagesync.models.FilesNotTieringError] - """ - - _validation = { - 'last_updated_timestamp': {'readonly': True}, - 'total_file_count': {'readonly': True, 'minimum': 0}, - 'errors': {'readonly': True}, - } - - _attribute_map = { - 'last_updated_timestamp': {'key': 'lastUpdatedTimestamp', 'type': 'iso-8601'}, - 'total_file_count': {'key': 'totalFileCount', 'type': 'long'}, - 'errors': {'key': 'errors', 'type': '[FilesNotTieringError]'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudTieringFilesNotTiering, self).__init__(**kwargs) - self.last_updated_timestamp = None - self.total_file_count = None - self.errors = None - - -class CloudTieringSpaceSavings(msrest.serialization.Model): - """Server endpoint cloud tiering status object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar last_updated_timestamp: Last updated timestamp. - :vartype last_updated_timestamp: ~datetime.datetime - :ivar volume_size_bytes: Volume size. - :vartype volume_size_bytes: long - :ivar total_size_cloud_bytes: Total size of content in the azure file share. - :vartype total_size_cloud_bytes: long - :ivar cached_size_bytes: Cached content size on the server. - :vartype cached_size_bytes: long - :ivar space_savings_percent: Percentage of cached size over total size. - :vartype space_savings_percent: int - :ivar space_savings_bytes: Count of bytes saved on the server. - :vartype space_savings_bytes: long - """ - - _validation = { - 'last_updated_timestamp': {'readonly': True}, - 'volume_size_bytes': {'readonly': True, 'minimum': 0}, - 'total_size_cloud_bytes': {'readonly': True, 'minimum': 0}, - 'cached_size_bytes': {'readonly': True, 'minimum': 0}, - 'space_savings_percent': {'readonly': True, 'maximum': 100, 'minimum': 0}, - 'space_savings_bytes': {'readonly': True, 'minimum': 0}, - } - - _attribute_map = { - 'last_updated_timestamp': {'key': 'lastUpdatedTimestamp', 'type': 'iso-8601'}, - 'volume_size_bytes': {'key': 'volumeSizeBytes', 'type': 'long'}, - 'total_size_cloud_bytes': {'key': 'totalSizeCloudBytes', 'type': 'long'}, - 'cached_size_bytes': {'key': 'cachedSizeBytes', 'type': 'long'}, - 'space_savings_percent': {'key': 'spaceSavingsPercent', 'type': 'int'}, - 'space_savings_bytes': {'key': 'spaceSavingsBytes', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudTieringSpaceSavings, self).__init__(**kwargs) - self.last_updated_timestamp = None - self.volume_size_bytes = None - self.total_size_cloud_bytes = None - self.cached_size_bytes = None - self.space_savings_percent = None - self.space_savings_bytes = None - - -class CloudTieringVolumeFreeSpacePolicyStatus(msrest.serialization.Model): - """Status of the volume free space policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar last_updated_timestamp: Last updated timestamp. - :vartype last_updated_timestamp: ~datetime.datetime - :ivar effective_volume_free_space_policy: In the case where multiple server endpoints are - present in a volume, an effective free space policy is applied. - :vartype effective_volume_free_space_policy: int - :ivar current_volume_free_space_percent: Current volume free space percentage. - :vartype current_volume_free_space_percent: int - """ - - _validation = { - 'last_updated_timestamp': {'readonly': True}, - 'effective_volume_free_space_policy': {'readonly': True, 'maximum': 100, 'minimum': 0}, - 'current_volume_free_space_percent': {'readonly': True, 'maximum': 100, 'minimum': 0}, - } - - _attribute_map = { - 'last_updated_timestamp': {'key': 'lastUpdatedTimestamp', 'type': 'iso-8601'}, - 'effective_volume_free_space_policy': {'key': 'effectiveVolumeFreeSpacePolicy', 'type': 'int'}, - 'current_volume_free_space_percent': {'key': 'currentVolumeFreeSpacePercent', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudTieringVolumeFreeSpacePolicyStatus, self).__init__(**kwargs) - self.last_updated_timestamp = None - self.effective_volume_free_space_policy = None - self.current_volume_free_space_percent = None - - -class FilesNotTieringError(msrest.serialization.Model): - """Files not tiering error object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error_code: Error code (HResult). - :vartype error_code: int - :ivar file_count: Count of files with this error. - :vartype file_count: long - """ - - _validation = { - 'error_code': {'readonly': True}, - 'file_count': {'readonly': True, 'minimum': 0}, - } - - _attribute_map = { - 'error_code': {'key': 'errorCode', 'type': 'int'}, - 'file_count': {'key': 'fileCount', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(FilesNotTieringError, self).__init__(**kwargs) - self.error_code = None - self.file_count = None - - -class OperationDisplayInfo(msrest.serialization.Model): - """The operation supported by storage sync. - - :param description: The description of the operation. - :type description: str - :param operation: The action that users can perform, based on their permission level. - :type operation: str - :param provider: Service provider: Microsoft StorageSync. - :type provider: str - :param resource: Resource on which the operation is performed. - :type resource: str - """ - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplayInfo, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.operation = kwargs.get('operation', None) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - - -class OperationDisplayResource(msrest.serialization.Model): - """Operation Display Resource object. - - :param provider: Operation Display Resource Provider. - :type provider: str - :param resource: Operation Display Resource. - :type resource: str - :param operation: Operation Display Resource Operation. - :type operation: str - :param description: Operation Display Resource Description. - :type description: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplayResource, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationEntity(msrest.serialization.Model): - """The operation supported by storage sync. - - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The operation supported by storage sync. - :type display: ~azure.mgmt.storagesync.models.OperationDisplayInfo - :param origin: The origin. - :type origin: str - :param properties: Properties of the operations resource. - :type properties: ~azure.mgmt.storagesync.models.OperationProperties - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplayInfo'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'OperationProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationEntity, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - self.properties = kwargs.get('properties', None) - - -class OperationEntityListResult(msrest.serialization.Model): - """The list of storage sync operations. - - :param next_link: The link used to get the next page of operations. - :type next_link: str - :param value: The list of operations. - :type value: list[~azure.mgmt.storagesync.models.OperationEntity] - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[OperationEntity]'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationEntityListResult, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs.get('value', None) - - -class OperationProperties(msrest.serialization.Model): - """Properties of the operations resource. - - :param service_specification: Service specification for the operations resource. - :type service_specification: - ~azure.mgmt.storagesync.models.OperationResourceServiceSpecification - """ - - _attribute_map = { - 'service_specification': {'key': 'serviceSpecification', 'type': 'OperationResourceServiceSpecification'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationProperties, self).__init__(**kwargs) - self.service_specification = kwargs.get('service_specification', None) - - -class OperationResourceMetricSpecification(msrest.serialization.Model): - """Operation Display Resource object. - - :param name: Name of the metric. - :type name: str - :param display_name: Display name for the metric. - :type display_name: str - :param display_description: Display description for the metric. - :type display_description: str - :param unit: Unit for the metric. - :type unit: str - :param aggregation_type: Aggregation type for the metric. - :type aggregation_type: str - :param fill_gap_with_zero: Fill gaps in the metric with zero. - :type fill_gap_with_zero: bool - :param dimensions: Dimensions for the metric specification. - :type dimensions: - list[~azure.mgmt.storagesync.models.OperationResourceMetricSpecificationDimension] - """ - - _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'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'dimensions': {'key': 'dimensions', 'type': '[OperationResourceMetricSpecificationDimension]'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationResourceMetricSpecification, 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.fill_gap_with_zero = kwargs.get('fill_gap_with_zero', None) - self.dimensions = kwargs.get('dimensions', None) - - -class OperationResourceMetricSpecificationDimension(msrest.serialization.Model): - """OperationResourceMetricSpecificationDimension object. - - :param name: Name of the dimension. - :type name: str - :param display_name: Display name of the dimensions. - :type display_name: str - :param to_be_exported_for_shoebox: Indicates metric should be exported for Shoebox. - :type to_be_exported_for_shoebox: bool - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationResourceMetricSpecificationDimension, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.to_be_exported_for_shoebox = kwargs.get('to_be_exported_for_shoebox', None) - - -class OperationResourceServiceSpecification(msrest.serialization.Model): - """Service specification. - - :param metric_specifications: List of metric specifications. - :type metric_specifications: - list[~azure.mgmt.storagesync.models.OperationResourceMetricSpecification] - """ - - _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[OperationResourceMetricSpecification]'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationResourceServiceSpecification, self).__init__(**kwargs) - self.metric_specifications = kwargs.get('metric_specifications', None) - - -class OperationStatus(msrest.serialization.Model): - """Operation status object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation Id. - :vartype name: str - :ivar status: Operation status. - :vartype status: str - :ivar start_time: Start time of the operation. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time of the operation. - :vartype end_time: ~datetime.datetime - :ivar error: Error details. - :vartype error: ~azure.mgmt.storagesync.models.StorageSyncApiError - """ - - _validation = { - 'name': {'readonly': True}, - 'status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'error': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'error': {'key': 'error', 'type': 'StorageSyncApiError'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationStatus, self).__init__(**kwargs) - self.name = None - self.status = None - self.start_time = None - self.end_time = None - self.error = None - - -class PostBackupResponse(msrest.serialization.Model): - """Post Backup Response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar cloud_endpoint_name: cloud endpoint Name. - :vartype cloud_endpoint_name: str - """ - - _validation = { - 'cloud_endpoint_name': {'readonly': True}, - } - - _attribute_map = { - 'cloud_endpoint_name': {'key': 'backupMetadata.cloudEndpointName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PostBackupResponse, self).__init__(**kwargs) - self.cloud_endpoint_name = None - - -class PostRestoreRequest(msrest.serialization.Model): - """Post Restore Request. - - :param partition: Post Restore partition. - :type partition: str - :param replica_group: Post Restore replica group. - :type replica_group: str - :param request_id: Post Restore request id. - :type request_id: str - :param azure_file_share_uri: Post Restore Azure file share uri. - :type azure_file_share_uri: str - :param status: Post Restore Azure status. - :type status: str - :param source_azure_file_share_uri: Post Restore Azure source azure file share uri. - :type source_azure_file_share_uri: str - :param failed_file_list: Post Restore Azure failed file list. - :type failed_file_list: str - :param restore_file_spec: Post Restore restore file spec array. - :type restore_file_spec: list[~azure.mgmt.storagesync.models.RestoreFileSpec] - """ - - _attribute_map = { - 'partition': {'key': 'partition', 'type': 'str'}, - 'replica_group': {'key': 'replicaGroup', 'type': 'str'}, - 'request_id': {'key': 'requestId', 'type': 'str'}, - 'azure_file_share_uri': {'key': 'azureFileShareUri', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'source_azure_file_share_uri': {'key': 'sourceAzureFileShareUri', 'type': 'str'}, - 'failed_file_list': {'key': 'failedFileList', 'type': 'str'}, - 'restore_file_spec': {'key': 'restoreFileSpec', 'type': '[RestoreFileSpec]'}, - } - - def __init__( - self, - **kwargs - ): - super(PostRestoreRequest, self).__init__(**kwargs) - self.partition = kwargs.get('partition', None) - self.replica_group = kwargs.get('replica_group', None) - self.request_id = kwargs.get('request_id', None) - self.azure_file_share_uri = kwargs.get('azure_file_share_uri', None) - self.status = kwargs.get('status', None) - self.source_azure_file_share_uri = kwargs.get('source_azure_file_share_uri', None) - self.failed_file_list = kwargs.get('failed_file_list', None) - self.restore_file_spec = kwargs.get('restore_file_spec', None) - - -class PreRestoreRequest(msrest.serialization.Model): - """Pre Restore request object. - - :param partition: Pre Restore partition. - :type partition: str - :param replica_group: Pre Restore replica group. - :type replica_group: str - :param request_id: Pre Restore request id. - :type request_id: str - :param azure_file_share_uri: Pre Restore Azure file share uri. - :type azure_file_share_uri: str - :param status: Pre Restore Azure status. - :type status: str - :param source_azure_file_share_uri: Pre Restore Azure source azure file share uri. - :type source_azure_file_share_uri: str - :param backup_metadata_property_bag: Pre Restore backup metadata property bag. - :type backup_metadata_property_bag: str - :param restore_file_spec: Pre Restore restore file spec array. - :type restore_file_spec: list[~azure.mgmt.storagesync.models.RestoreFileSpec] - :param pause_wait_for_sync_drain_time_period_in_seconds: Pre Restore pause wait for sync drain - time period in seconds. - :type pause_wait_for_sync_drain_time_period_in_seconds: int - """ - - _attribute_map = { - 'partition': {'key': 'partition', 'type': 'str'}, - 'replica_group': {'key': 'replicaGroup', 'type': 'str'}, - 'request_id': {'key': 'requestId', 'type': 'str'}, - 'azure_file_share_uri': {'key': 'azureFileShareUri', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'source_azure_file_share_uri': {'key': 'sourceAzureFileShareUri', 'type': 'str'}, - 'backup_metadata_property_bag': {'key': 'backupMetadataPropertyBag', 'type': 'str'}, - 'restore_file_spec': {'key': 'restoreFileSpec', 'type': '[RestoreFileSpec]'}, - 'pause_wait_for_sync_drain_time_period_in_seconds': {'key': 'pauseWaitForSyncDrainTimePeriodInSeconds', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(PreRestoreRequest, self).__init__(**kwargs) - self.partition = kwargs.get('partition', None) - self.replica_group = kwargs.get('replica_group', None) - self.request_id = kwargs.get('request_id', None) - self.azure_file_share_uri = kwargs.get('azure_file_share_uri', None) - self.status = kwargs.get('status', None) - self.source_azure_file_share_uri = kwargs.get('source_azure_file_share_uri', None) - self.backup_metadata_property_bag = kwargs.get('backup_metadata_property_bag', None) - self.restore_file_spec = kwargs.get('restore_file_spec', None) - self.pause_wait_for_sync_drain_time_period_in_seconds = kwargs.get('pause_wait_for_sync_drain_time_period_in_seconds', None) - - -class PrivateEndpoint(msrest.serialization.Model): - """The Private Endpoint resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The ARM identifier for Private Endpoint. - :vartype id: str - """ - - _validation = { - 'id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpoint, self).__init__(**kwargs) - self.id = None - - -class PrivateEndpointConnection(Resource): - """The Private Endpoint Connection resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param private_endpoint: The resource of private end point. - :type private_endpoint: ~azure.mgmt.storagesync.models.PrivateEndpoint - :param private_link_service_connection_state: A collection of information about the state of - the connection between service consumer and provider. - :type private_link_service_connection_state: - ~azure.mgmt.storagesync.models.PrivateLinkServiceConnectionState - :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Possible values include: "Succeeded", "Creating", "Deleting", "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.storagesync.models.PrivateEndpointConnectionProvisioningState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnection, self).__init__(**kwargs) - self.private_endpoint = kwargs.get('private_endpoint', None) - self.private_link_service_connection_state = kwargs.get('private_link_service_connection_state', None) - self.provisioning_state = None - - -class PrivateEndpointConnectionListResult(msrest.serialization.Model): - """List of private endpoint connection associated with the specified storage account. - - :param value: Array of private endpoint connections. - :type value: list[~azure.mgmt.storagesync.models.PrivateEndpointConnection] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class PrivateLinkResource(Resource): - """A private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar group_id: The private link resource group id. - :vartype group_id: str - :ivar required_members: The private link resource required member names. - :vartype required_members: list[str] - :param required_zone_names: The private link resource Private link DNS zone name. - :type required_zone_names: list[str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResource, self).__init__(**kwargs) - self.group_id = None - self.required_members = None - self.required_zone_names = kwargs.get('required_zone_names', None) - - -class PrivateLinkResourceListResult(msrest.serialization.Model): - """A list of private link resources. - - :param value: Array of private link resources. - :type value: list[~azure.mgmt.storagesync.models.PrivateLinkResource] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResourceListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class PrivateLinkServiceConnectionState(msrest.serialization.Model): - """A collection of information about the state of the connection between service consumer and provider. - - :param status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Possible values include: "Pending", "Approved", "Rejected". - :type status: str or ~azure.mgmt.storagesync.models.PrivateEndpointServiceConnectionStatus - :param description: The reason for approval/rejection of the connection. - :type description: str - :param actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :type actions_required: str - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.description = kwargs.get('description', None) - self.actions_required = kwargs.get('actions_required', None) - - -class RecallActionParameters(msrest.serialization.Model): - """The parameters used when calling recall action on server endpoint. - - :param pattern: Pattern of the files. - :type pattern: str - :param recall_path: Recall path. - :type recall_path: str - """ - - _attribute_map = { - 'pattern': {'key': 'pattern', 'type': 'str'}, - 'recall_path': {'key': 'recallPath', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RecallActionParameters, self).__init__(**kwargs) - self.pattern = kwargs.get('pattern', None) - self.recall_path = kwargs.get('recall_path', None) - - -class RegisteredServer(ProxyResource): - """Registered Server resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param server_certificate: Registered Server Certificate. - :type server_certificate: str - :param agent_version: Registered Server Agent Version. - :type agent_version: str - :ivar agent_version_status: Registered Server Agent Version Status. Possible values include: - "Ok", "NearExpiry", "Expired", "Blocked". - :vartype agent_version_status: str or - ~azure.mgmt.storagesync.models.RegisteredServerAgentVersionStatus - :ivar agent_version_expiration_date: Registered Server Agent Version Expiration Date. - :vartype agent_version_expiration_date: ~datetime.datetime - :param server_os_version: Registered Server OS Version. - :type server_os_version: str - :ivar server_management_error_code: Registered Server Management Error Code. - :vartype server_management_error_code: int - :ivar last_heart_beat: Registered Server last heart beat. - :vartype last_heart_beat: ~datetime.datetime - :ivar provisioning_state: Registered Server Provisioning State. - :vartype provisioning_state: str - :param server_role: Registered Server serverRole. - :type server_role: str - :param cluster_id: Registered Server clusterId. - :type cluster_id: str - :param cluster_name: Registered Server clusterName. - :type cluster_name: str - :param server_id: Registered Server serverId. - :type server_id: str - :ivar storage_sync_service_uid: Registered Server storageSyncServiceUid. - :vartype storage_sync_service_uid: str - :ivar last_workflow_id: Registered Server lastWorkflowId. - :vartype last_workflow_id: str - :ivar last_operation_name: Resource Last Operation Name. - :vartype last_operation_name: str - :ivar discovery_endpoint_uri: Resource discoveryEndpointUri. - :vartype discovery_endpoint_uri: str - :ivar resource_location: Resource Location. - :vartype resource_location: str - :ivar service_location: Service Location. - :vartype service_location: str - :param friendly_name: Friendly Name. - :type friendly_name: str - :ivar management_endpoint_uri: Management Endpoint Uri. - :vartype management_endpoint_uri: str - :ivar monitoring_endpoint_uri: Telemetry Endpoint Uri. - :vartype monitoring_endpoint_uri: str - :ivar monitoring_configuration: Monitoring Configuration. - :vartype monitoring_configuration: str - :ivar server_name: Server name. - :vartype server_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'agent_version_status': {'readonly': True}, - 'agent_version_expiration_date': {'readonly': True}, - 'server_management_error_code': {'readonly': True}, - 'last_heart_beat': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'storage_sync_service_uid': {'readonly': True}, - 'last_workflow_id': {'readonly': True}, - 'last_operation_name': {'readonly': True}, - 'discovery_endpoint_uri': {'readonly': True}, - 'resource_location': {'readonly': True}, - 'service_location': {'readonly': True}, - 'management_endpoint_uri': {'readonly': True}, - 'monitoring_endpoint_uri': {'readonly': True}, - 'monitoring_configuration': {'readonly': True}, - 'server_name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'server_certificate': {'key': 'properties.serverCertificate', 'type': 'str'}, - 'agent_version': {'key': 'properties.agentVersion', 'type': 'str'}, - 'agent_version_status': {'key': 'properties.agentVersionStatus', 'type': 'str'}, - 'agent_version_expiration_date': {'key': 'properties.agentVersionExpirationDate', 'type': 'iso-8601'}, - 'server_os_version': {'key': 'properties.serverOSVersion', 'type': 'str'}, - 'server_management_error_code': {'key': 'properties.serverManagementErrorCode', 'type': 'int'}, - 'last_heart_beat': {'key': 'properties.lastHeartBeat', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'server_role': {'key': 'properties.serverRole', 'type': 'str'}, - 'cluster_id': {'key': 'properties.clusterId', 'type': 'str'}, - 'cluster_name': {'key': 'properties.clusterName', 'type': 'str'}, - 'server_id': {'key': 'properties.serverId', 'type': 'str'}, - 'storage_sync_service_uid': {'key': 'properties.storageSyncServiceUid', 'type': 'str'}, - 'last_workflow_id': {'key': 'properties.lastWorkflowId', 'type': 'str'}, - 'last_operation_name': {'key': 'properties.lastOperationName', 'type': 'str'}, - 'discovery_endpoint_uri': {'key': 'properties.discoveryEndpointUri', 'type': 'str'}, - 'resource_location': {'key': 'properties.resourceLocation', 'type': 'str'}, - 'service_location': {'key': 'properties.serviceLocation', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'management_endpoint_uri': {'key': 'properties.managementEndpointUri', 'type': 'str'}, - 'monitoring_endpoint_uri': {'key': 'properties.monitoringEndpointUri', 'type': 'str'}, - 'monitoring_configuration': {'key': 'properties.monitoringConfiguration', 'type': 'str'}, - 'server_name': {'key': 'properties.serverName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RegisteredServer, self).__init__(**kwargs) - self.server_certificate = kwargs.get('server_certificate', None) - self.agent_version = kwargs.get('agent_version', None) - self.agent_version_status = None - self.agent_version_expiration_date = None - self.server_os_version = kwargs.get('server_os_version', None) - self.server_management_error_code = None - self.last_heart_beat = None - self.provisioning_state = None - self.server_role = kwargs.get('server_role', None) - self.cluster_id = kwargs.get('cluster_id', None) - self.cluster_name = kwargs.get('cluster_name', None) - self.server_id = kwargs.get('server_id', None) - self.storage_sync_service_uid = None - self.last_workflow_id = None - self.last_operation_name = None - self.discovery_endpoint_uri = None - self.resource_location = None - self.service_location = None - self.friendly_name = kwargs.get('friendly_name', None) - self.management_endpoint_uri = None - self.monitoring_endpoint_uri = None - self.monitoring_configuration = None - self.server_name = None - - -class RegisteredServerArray(msrest.serialization.Model): - """Array of RegisteredServer. - - :param value: Collection of Registered Server. - :type value: list[~azure.mgmt.storagesync.models.RegisteredServer] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RegisteredServer]'}, - } - - def __init__( - self, - **kwargs - ): - super(RegisteredServerArray, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class RegisteredServerCreateParameters(ProxyResource): - """The parameters used when creating a registered server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param server_certificate: Registered Server Certificate. - :type server_certificate: str - :param agent_version: Registered Server Agent Version. - :type agent_version: str - :param server_os_version: Registered Server OS Version. - :type server_os_version: str - :param last_heart_beat: Registered Server last heart beat. - :type last_heart_beat: str - :param server_role: Registered Server serverRole. - :type server_role: str - :param cluster_id: Registered Server clusterId. - :type cluster_id: str - :param cluster_name: Registered Server clusterName. - :type cluster_name: str - :param server_id: Registered Server serverId. - :type server_id: str - :param friendly_name: Friendly Name. - :type friendly_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'server_certificate': {'key': 'properties.serverCertificate', 'type': 'str'}, - 'agent_version': {'key': 'properties.agentVersion', 'type': 'str'}, - 'server_os_version': {'key': 'properties.serverOSVersion', 'type': 'str'}, - 'last_heart_beat': {'key': 'properties.lastHeartBeat', 'type': 'str'}, - 'server_role': {'key': 'properties.serverRole', 'type': 'str'}, - 'cluster_id': {'key': 'properties.clusterId', 'type': 'str'}, - 'cluster_name': {'key': 'properties.clusterName', 'type': 'str'}, - 'server_id': {'key': 'properties.serverId', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RegisteredServerCreateParameters, self).__init__(**kwargs) - self.server_certificate = kwargs.get('server_certificate', None) - self.agent_version = kwargs.get('agent_version', None) - self.server_os_version = kwargs.get('server_os_version', None) - self.last_heart_beat = kwargs.get('last_heart_beat', None) - self.server_role = kwargs.get('server_role', None) - self.cluster_id = kwargs.get('cluster_id', None) - self.cluster_name = kwargs.get('cluster_name', None) - self.server_id = kwargs.get('server_id', None) - self.friendly_name = kwargs.get('friendly_name', None) - - -class ResourcesMoveInfo(msrest.serialization.Model): - """Resource Move Info. - - :param target_resource_group: Target resource group. - :type target_resource_group: str - :param resources: Collection of Resources. - :type resources: list[str] - """ - - _attribute_map = { - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, - 'resources': {'key': 'resources', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourcesMoveInfo, self).__init__(**kwargs) - self.target_resource_group = kwargs.get('target_resource_group', None) - self.resources = kwargs.get('resources', None) - - -class RestoreFileSpec(msrest.serialization.Model): - """Restore file spec. - - :param path: Restore file spec path. - :type path: str - :param isdir: Restore file spec isdir. - :type isdir: bool - """ - - _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'isdir': {'key': 'isdir', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(RestoreFileSpec, self).__init__(**kwargs) - self.path = kwargs.get('path', None) - self.isdir = kwargs.get('isdir', None) - - -class ServerEndpoint(ProxyResource): - """Server Endpoint object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param server_local_path: Server Local path. - :type server_local_path: str - :param cloud_tiering: Cloud Tiering. Possible values include: "on", "off". - :type cloud_tiering: str or ~azure.mgmt.storagesync.models.FeatureStatus - :param volume_free_space_percent: Level of free space to be maintained by Cloud Tiering if it - is enabled. - :type volume_free_space_percent: int - :param tier_files_older_than_days: Tier files older than days. - :type tier_files_older_than_days: int - :param friendly_name: Friendly Name. - :type friendly_name: str - :param server_resource_id: Server Resource Id. - :type server_resource_id: str - :ivar provisioning_state: ServerEndpoint Provisioning State. - :vartype provisioning_state: str - :ivar last_workflow_id: ServerEndpoint lastWorkflowId. - :vartype last_workflow_id: str - :ivar last_operation_name: Resource Last Operation Name. - :vartype last_operation_name: str - :ivar sync_status: Server Endpoint sync status. - :vartype sync_status: ~azure.mgmt.storagesync.models.ServerEndpointSyncStatus - :param offline_data_transfer: Offline data transfer. Possible values include: "on", "off". - :type offline_data_transfer: str or ~azure.mgmt.storagesync.models.FeatureStatus - :ivar offline_data_transfer_storage_account_resource_id: Offline data transfer storage account - resource ID. - :vartype offline_data_transfer_storage_account_resource_id: str - :ivar offline_data_transfer_storage_account_tenant_id: Offline data transfer storage account - tenant ID. - :vartype offline_data_transfer_storage_account_tenant_id: str - :param offline_data_transfer_share_name: Offline data transfer share name. - :type offline_data_transfer_share_name: str - :ivar cloud_tiering_status: Cloud tiering status. Only populated if cloud tiering is enabled. - :vartype cloud_tiering_status: ~azure.mgmt.storagesync.models.ServerEndpointCloudTieringStatus - :ivar recall_status: Recall status. Only populated if cloud tiering is enabled. - :vartype recall_status: ~azure.mgmt.storagesync.models.ServerEndpointRecallStatus - :param initial_download_policy: Policy for how namespace and files are recalled during FastDr. - Possible values include: "NamespaceOnly", "NamespaceThenModifiedFiles", "AvoidTieredFiles". - :type initial_download_policy: str or ~azure.mgmt.storagesync.models.InitialDownloadPolicy - :param local_cache_mode: Policy for enabling follow-the-sun business models: link local cache - to cloud behavior to pre-populate before local access. Possible values include: - "DownloadNewAndModifiedFiles", "UpdateLocallyCachedFiles". - :type local_cache_mode: str or ~azure.mgmt.storagesync.models.LocalCacheMode - :ivar server_name: Server name. - :vartype server_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'volume_free_space_percent': {'maximum': 100, 'minimum': 0}, - 'tier_files_older_than_days': {'maximum': 2147483647, 'minimum': 0}, - 'provisioning_state': {'readonly': True}, - 'last_workflow_id': {'readonly': True}, - 'last_operation_name': {'readonly': True}, - 'sync_status': {'readonly': True}, - 'offline_data_transfer_storage_account_resource_id': {'readonly': True}, - 'offline_data_transfer_storage_account_tenant_id': {'readonly': True}, - 'cloud_tiering_status': {'readonly': True}, - 'recall_status': {'readonly': True}, - 'server_name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'server_local_path': {'key': 'properties.serverLocalPath', 'type': 'str'}, - 'cloud_tiering': {'key': 'properties.cloudTiering', 'type': 'str'}, - 'volume_free_space_percent': {'key': 'properties.volumeFreeSpacePercent', 'type': 'int'}, - 'tier_files_older_than_days': {'key': 'properties.tierFilesOlderThanDays', 'type': 'int'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'server_resource_id': {'key': 'properties.serverResourceId', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'last_workflow_id': {'key': 'properties.lastWorkflowId', 'type': 'str'}, - 'last_operation_name': {'key': 'properties.lastOperationName', 'type': 'str'}, - 'sync_status': {'key': 'properties.syncStatus', 'type': 'ServerEndpointSyncStatus'}, - 'offline_data_transfer': {'key': 'properties.offlineDataTransfer', 'type': 'str'}, - 'offline_data_transfer_storage_account_resource_id': {'key': 'properties.offlineDataTransferStorageAccountResourceId', 'type': 'str'}, - 'offline_data_transfer_storage_account_tenant_id': {'key': 'properties.offlineDataTransferStorageAccountTenantId', 'type': 'str'}, - 'offline_data_transfer_share_name': {'key': 'properties.offlineDataTransferShareName', 'type': 'str'}, - 'cloud_tiering_status': {'key': 'properties.cloudTieringStatus', 'type': 'ServerEndpointCloudTieringStatus'}, - 'recall_status': {'key': 'properties.recallStatus', 'type': 'ServerEndpointRecallStatus'}, - 'initial_download_policy': {'key': 'properties.initialDownloadPolicy', 'type': 'str'}, - 'local_cache_mode': {'key': 'properties.localCacheMode', 'type': 'str'}, - 'server_name': {'key': 'properties.serverName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerEndpoint, self).__init__(**kwargs) - self.server_local_path = kwargs.get('server_local_path', None) - self.cloud_tiering = kwargs.get('cloud_tiering', None) - self.volume_free_space_percent = kwargs.get('volume_free_space_percent', None) - self.tier_files_older_than_days = kwargs.get('tier_files_older_than_days', None) - self.friendly_name = kwargs.get('friendly_name', None) - self.server_resource_id = kwargs.get('server_resource_id', None) - self.provisioning_state = None - self.last_workflow_id = None - self.last_operation_name = None - self.sync_status = None - self.offline_data_transfer = kwargs.get('offline_data_transfer', None) - self.offline_data_transfer_storage_account_resource_id = None - self.offline_data_transfer_storage_account_tenant_id = None - self.offline_data_transfer_share_name = kwargs.get('offline_data_transfer_share_name', None) - self.cloud_tiering_status = None - self.recall_status = None - self.initial_download_policy = kwargs.get('initial_download_policy', None) - self.local_cache_mode = kwargs.get('local_cache_mode', None) - self.server_name = None - - -class ServerEndpointArray(msrest.serialization.Model): - """Array of ServerEndpoint. - - :param value: Collection of ServerEndpoint. - :type value: list[~azure.mgmt.storagesync.models.ServerEndpoint] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ServerEndpoint]'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerEndpointArray, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class ServerEndpointBackgroundDataDownloadActivity(msrest.serialization.Model): - """Background data download activity object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar timestamp: Timestamp when properties were updated. - :vartype timestamp: ~datetime.datetime - :ivar percent_progress: Progress percentage. - :vartype percent_progress: int - :ivar downloaded_bytes: Running count of bytes downloaded. - :vartype downloaded_bytes: long - """ - - _validation = { - 'timestamp': {'readonly': True}, - 'percent_progress': {'readonly': True, 'maximum': 100, 'minimum': 0}, - 'downloaded_bytes': {'readonly': True, 'minimum': 0}, - } - - _attribute_map = { - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'percent_progress': {'key': 'percentProgress', 'type': 'int'}, - 'downloaded_bytes': {'key': 'downloadedBytes', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerEndpointBackgroundDataDownloadActivity, self).__init__(**kwargs) - self.timestamp = None - self.percent_progress = None - self.downloaded_bytes = None - - -class ServerEndpointCloudTieringStatus(msrest.serialization.Model): - """Server endpoint cloud tiering status object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar last_updated_timestamp: Last updated timestamp. - :vartype last_updated_timestamp: ~datetime.datetime - :ivar health: Cloud tiering health state. Possible values include: "Unavailable", "Healthy", - "Error". - :vartype health: str or ~azure.mgmt.storagesync.models.ServerEndpointHealthState - :ivar health_last_updated_timestamp: The last updated timestamp of health state. - :vartype health_last_updated_timestamp: ~datetime.datetime - :ivar last_cloud_tiering_result: Last cloud tiering result (HResult). - :vartype last_cloud_tiering_result: int - :ivar last_success_timestamp: Last cloud tiering success timestamp. - :vartype last_success_timestamp: ~datetime.datetime - :ivar space_savings: Information regarding how much local space cloud tiering is saving. - :vartype space_savings: ~azure.mgmt.storagesync.models.CloudTieringSpaceSavings - :ivar cache_performance: Information regarding how well the local cache on the server is - performing. - :vartype cache_performance: ~azure.mgmt.storagesync.models.CloudTieringCachePerformance - :ivar files_not_tiering: Information regarding files that failed to be tiered. - :vartype files_not_tiering: ~azure.mgmt.storagesync.models.CloudTieringFilesNotTiering - :ivar volume_free_space_policy_status: Status of the volume free space policy. - :vartype volume_free_space_policy_status: - ~azure.mgmt.storagesync.models.CloudTieringVolumeFreeSpacePolicyStatus - :ivar date_policy_status: Status of the date policy. - :vartype date_policy_status: ~azure.mgmt.storagesync.models.CloudTieringDatePolicyStatus - """ - - _validation = { - 'last_updated_timestamp': {'readonly': True}, - 'health': {'readonly': True}, - 'health_last_updated_timestamp': {'readonly': True}, - 'last_cloud_tiering_result': {'readonly': True}, - 'last_success_timestamp': {'readonly': True}, - 'space_savings': {'readonly': True}, - 'cache_performance': {'readonly': True}, - 'files_not_tiering': {'readonly': True}, - 'volume_free_space_policy_status': {'readonly': True}, - 'date_policy_status': {'readonly': True}, - } - - _attribute_map = { - 'last_updated_timestamp': {'key': 'lastUpdatedTimestamp', 'type': 'iso-8601'}, - 'health': {'key': 'health', 'type': 'str'}, - 'health_last_updated_timestamp': {'key': 'healthLastUpdatedTimestamp', 'type': 'iso-8601'}, - 'last_cloud_tiering_result': {'key': 'lastCloudTieringResult', 'type': 'int'}, - 'last_success_timestamp': {'key': 'lastSuccessTimestamp', 'type': 'iso-8601'}, - 'space_savings': {'key': 'spaceSavings', 'type': 'CloudTieringSpaceSavings'}, - 'cache_performance': {'key': 'cachePerformance', 'type': 'CloudTieringCachePerformance'}, - 'files_not_tiering': {'key': 'filesNotTiering', 'type': 'CloudTieringFilesNotTiering'}, - 'volume_free_space_policy_status': {'key': 'volumeFreeSpacePolicyStatus', 'type': 'CloudTieringVolumeFreeSpacePolicyStatus'}, - 'date_policy_status': {'key': 'datePolicyStatus', 'type': 'CloudTieringDatePolicyStatus'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerEndpointCloudTieringStatus, self).__init__(**kwargs) - self.last_updated_timestamp = None - self.health = None - self.health_last_updated_timestamp = None - self.last_cloud_tiering_result = None - self.last_success_timestamp = None - self.space_savings = None - self.cache_performance = None - self.files_not_tiering = None - self.volume_free_space_policy_status = None - self.date_policy_status = None - - -class ServerEndpointCreateParameters(ProxyResource): - """The parameters used when creating a server endpoint. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param server_local_path: Server Local path. - :type server_local_path: str - :param cloud_tiering: Cloud Tiering. Possible values include: "on", "off". - :type cloud_tiering: str or ~azure.mgmt.storagesync.models.FeatureStatus - :param volume_free_space_percent: Level of free space to be maintained by Cloud Tiering if it - is enabled. - :type volume_free_space_percent: int - :param tier_files_older_than_days: Tier files older than days. - :type tier_files_older_than_days: int - :param friendly_name: Friendly Name. - :type friendly_name: str - :param server_resource_id: Server Resource Id. - :type server_resource_id: str - :param offline_data_transfer: Offline data transfer. Possible values include: "on", "off". - :type offline_data_transfer: str or ~azure.mgmt.storagesync.models.FeatureStatus - :param offline_data_transfer_share_name: Offline data transfer share name. - :type offline_data_transfer_share_name: str - :param initial_download_policy: Policy for how namespace and files are recalled during FastDr. - Possible values include: "NamespaceOnly", "NamespaceThenModifiedFiles", "AvoidTieredFiles". - :type initial_download_policy: str or ~azure.mgmt.storagesync.models.InitialDownloadPolicy - :param local_cache_mode: Policy for enabling follow-the-sun business models: link local cache - to cloud behavior to pre-populate before local access. Possible values include: - "DownloadNewAndModifiedFiles", "UpdateLocallyCachedFiles". - :type local_cache_mode: str or ~azure.mgmt.storagesync.models.LocalCacheMode - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'volume_free_space_percent': {'maximum': 100, 'minimum': 0}, - 'tier_files_older_than_days': {'maximum': 2147483647, 'minimum': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'server_local_path': {'key': 'properties.serverLocalPath', 'type': 'str'}, - 'cloud_tiering': {'key': 'properties.cloudTiering', 'type': 'str'}, - 'volume_free_space_percent': {'key': 'properties.volumeFreeSpacePercent', 'type': 'int'}, - 'tier_files_older_than_days': {'key': 'properties.tierFilesOlderThanDays', 'type': 'int'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'server_resource_id': {'key': 'properties.serverResourceId', 'type': 'str'}, - 'offline_data_transfer': {'key': 'properties.offlineDataTransfer', 'type': 'str'}, - 'offline_data_transfer_share_name': {'key': 'properties.offlineDataTransferShareName', 'type': 'str'}, - 'initial_download_policy': {'key': 'properties.initialDownloadPolicy', 'type': 'str'}, - 'local_cache_mode': {'key': 'properties.localCacheMode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerEndpointCreateParameters, self).__init__(**kwargs) - self.server_local_path = kwargs.get('server_local_path', None) - self.cloud_tiering = kwargs.get('cloud_tiering', None) - self.volume_free_space_percent = kwargs.get('volume_free_space_percent', None) - self.tier_files_older_than_days = kwargs.get('tier_files_older_than_days', None) - self.friendly_name = kwargs.get('friendly_name', None) - self.server_resource_id = kwargs.get('server_resource_id', None) - self.offline_data_transfer = kwargs.get('offline_data_transfer', None) - self.offline_data_transfer_share_name = kwargs.get('offline_data_transfer_share_name', None) - self.initial_download_policy = kwargs.get('initial_download_policy', None) - self.local_cache_mode = kwargs.get('local_cache_mode', None) - - -class ServerEndpointFilesNotSyncingError(msrest.serialization.Model): - """Files not syncing error object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error_code: Error code (HResult). - :vartype error_code: int - :ivar persistent_count: Count of persistent files not syncing with the specified error code. - :vartype persistent_count: long - :ivar transient_count: Count of transient files not syncing with the specified error code. - :vartype transient_count: long - """ - - _validation = { - 'error_code': {'readonly': True}, - 'persistent_count': {'readonly': True, 'minimum': 0}, - 'transient_count': {'readonly': True, 'minimum': 0}, - } - - _attribute_map = { - 'error_code': {'key': 'errorCode', 'type': 'int'}, - 'persistent_count': {'key': 'persistentCount', 'type': 'long'}, - 'transient_count': {'key': 'transientCount', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerEndpointFilesNotSyncingError, self).__init__(**kwargs) - self.error_code = None - self.persistent_count = None - self.transient_count = None - - -class ServerEndpointRecallError(msrest.serialization.Model): - """Server endpoint recall error object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error_code: Error code (HResult). - :vartype error_code: int - :ivar count: Count of occurences of the error. - :vartype count: long - """ - - _validation = { - 'error_code': {'readonly': True}, - 'count': {'readonly': True, 'minimum': 0}, - } - - _attribute_map = { - 'error_code': {'key': 'errorCode', 'type': 'int'}, - 'count': {'key': 'count', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerEndpointRecallError, self).__init__(**kwargs) - self.error_code = None - self.count = None - - -class ServerEndpointRecallStatus(msrest.serialization.Model): - """Server endpoint recall status object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar last_updated_timestamp: Last updated timestamp. - :vartype last_updated_timestamp: ~datetime.datetime - :ivar total_recall_errors_count: Total count of recall errors. - :vartype total_recall_errors_count: long - :ivar recall_errors: Array of recall errors. - :vartype recall_errors: list[~azure.mgmt.storagesync.models.ServerEndpointRecallError] - """ - - _validation = { - 'last_updated_timestamp': {'readonly': True}, - 'total_recall_errors_count': {'readonly': True, 'minimum': 0}, - 'recall_errors': {'readonly': True}, - } - - _attribute_map = { - 'last_updated_timestamp': {'key': 'lastUpdatedTimestamp', 'type': 'iso-8601'}, - 'total_recall_errors_count': {'key': 'totalRecallErrorsCount', 'type': 'long'}, - 'recall_errors': {'key': 'recallErrors', 'type': '[ServerEndpointRecallError]'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerEndpointRecallStatus, self).__init__(**kwargs) - self.last_updated_timestamp = None - self.total_recall_errors_count = None - self.recall_errors = None - - -class ServerEndpointSyncActivityStatus(msrest.serialization.Model): - """Sync Session status object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar timestamp: Timestamp when properties were updated. - :vartype timestamp: ~datetime.datetime - :ivar per_item_error_count: Per item error count. - :vartype per_item_error_count: long - :ivar applied_item_count: Applied item count. - :vartype applied_item_count: long - :ivar total_item_count: Total item count (if available). - :vartype total_item_count: long - :ivar applied_bytes: Applied bytes. - :vartype applied_bytes: long - :ivar total_bytes: Total bytes (if available). - :vartype total_bytes: long - :ivar sync_mode: Sync mode. Possible values include: "Regular", "NamespaceDownload", - "InitialUpload", "SnapshotUpload", "InitialFullDownload". - :vartype sync_mode: str or ~azure.mgmt.storagesync.models.ServerEndpointSyncMode - """ - - _validation = { - 'timestamp': {'readonly': True}, - 'per_item_error_count': {'readonly': True, 'minimum': 0}, - 'applied_item_count': {'readonly': True, 'minimum': 0}, - 'total_item_count': {'readonly': True, 'minimum': 0}, - 'applied_bytes': {'readonly': True, 'minimum': 0}, - 'total_bytes': {'readonly': True, 'minimum': 0}, - 'sync_mode': {'readonly': True}, - } - - _attribute_map = { - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'per_item_error_count': {'key': 'perItemErrorCount', 'type': 'long'}, - 'applied_item_count': {'key': 'appliedItemCount', 'type': 'long'}, - 'total_item_count': {'key': 'totalItemCount', 'type': 'long'}, - 'applied_bytes': {'key': 'appliedBytes', 'type': 'long'}, - 'total_bytes': {'key': 'totalBytes', 'type': 'long'}, - 'sync_mode': {'key': 'syncMode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerEndpointSyncActivityStatus, self).__init__(**kwargs) - self.timestamp = None - self.per_item_error_count = None - self.applied_item_count = None - self.total_item_count = None - self.applied_bytes = None - self.total_bytes = None - self.sync_mode = None - - -class ServerEndpointSyncSessionStatus(msrest.serialization.Model): - """Sync Session status object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar last_sync_result: Last sync result (HResult). - :vartype last_sync_result: int - :ivar last_sync_timestamp: Last sync timestamp. - :vartype last_sync_timestamp: ~datetime.datetime - :ivar last_sync_success_timestamp: Last sync success timestamp. - :vartype last_sync_success_timestamp: ~datetime.datetime - :ivar last_sync_per_item_error_count: Last sync per item error count. - :vartype last_sync_per_item_error_count: long - :ivar persistent_files_not_syncing_count: Count of persistent files not syncing. - :vartype persistent_files_not_syncing_count: long - :ivar transient_files_not_syncing_count: Count of transient files not syncing. - :vartype transient_files_not_syncing_count: long - :ivar files_not_syncing_errors: Array of per-item errors coming from the last sync session. - :vartype files_not_syncing_errors: - list[~azure.mgmt.storagesync.models.ServerEndpointFilesNotSyncingError] - :ivar last_sync_mode: Sync mode. Possible values include: "Regular", "NamespaceDownload", - "InitialUpload", "SnapshotUpload", "InitialFullDownload". - :vartype last_sync_mode: str or ~azure.mgmt.storagesync.models.ServerEndpointSyncMode - """ - - _validation = { - 'last_sync_result': {'readonly': True}, - 'last_sync_timestamp': {'readonly': True}, - 'last_sync_success_timestamp': {'readonly': True}, - 'last_sync_per_item_error_count': {'readonly': True, 'minimum': 0}, - 'persistent_files_not_syncing_count': {'readonly': True, 'minimum': 0}, - 'transient_files_not_syncing_count': {'readonly': True, 'minimum': 0}, - 'files_not_syncing_errors': {'readonly': True}, - 'last_sync_mode': {'readonly': True}, - } - - _attribute_map = { - 'last_sync_result': {'key': 'lastSyncResult', 'type': 'int'}, - 'last_sync_timestamp': {'key': 'lastSyncTimestamp', 'type': 'iso-8601'}, - 'last_sync_success_timestamp': {'key': 'lastSyncSuccessTimestamp', 'type': 'iso-8601'}, - 'last_sync_per_item_error_count': {'key': 'lastSyncPerItemErrorCount', 'type': 'long'}, - 'persistent_files_not_syncing_count': {'key': 'persistentFilesNotSyncingCount', 'type': 'long'}, - 'transient_files_not_syncing_count': {'key': 'transientFilesNotSyncingCount', 'type': 'long'}, - 'files_not_syncing_errors': {'key': 'filesNotSyncingErrors', 'type': '[ServerEndpointFilesNotSyncingError]'}, - 'last_sync_mode': {'key': 'lastSyncMode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerEndpointSyncSessionStatus, self).__init__(**kwargs) - self.last_sync_result = None - self.last_sync_timestamp = None - self.last_sync_success_timestamp = None - self.last_sync_per_item_error_count = None - self.persistent_files_not_syncing_count = None - self.transient_files_not_syncing_count = None - self.files_not_syncing_errors = None - self.last_sync_mode = None - - -class ServerEndpointSyncStatus(msrest.serialization.Model): - """Server Endpoint sync status. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar download_health: Download Health Status. Possible values include: "Unavailable", - "Healthy", "Error". - :vartype download_health: str or ~azure.mgmt.storagesync.models.ServerEndpointHealthState - :ivar upload_health: Upload Health Status. Possible values include: "Unavailable", "Healthy", - "Error". - :vartype upload_health: str or ~azure.mgmt.storagesync.models.ServerEndpointHealthState - :ivar combined_health: Combined Health Status. Possible values include: "Unavailable", - "Healthy", "Error". - :vartype combined_health: str or ~azure.mgmt.storagesync.models.ServerEndpointHealthState - :ivar sync_activity: Sync activity. Possible values include: "Upload", "Download", - "UploadAndDownload". - :vartype sync_activity: str or ~azure.mgmt.storagesync.models.ServerEndpointSyncActivityState - :ivar total_persistent_files_not_syncing_count: Total count of persistent files not syncing - (combined upload + download). - :vartype total_persistent_files_not_syncing_count: long - :ivar last_updated_timestamp: Last Updated Timestamp. - :vartype last_updated_timestamp: ~datetime.datetime - :ivar upload_status: Upload Status. - :vartype upload_status: ~azure.mgmt.storagesync.models.ServerEndpointSyncSessionStatus - :ivar download_status: Download Status. - :vartype download_status: ~azure.mgmt.storagesync.models.ServerEndpointSyncSessionStatus - :ivar upload_activity: Upload sync activity. - :vartype upload_activity: ~azure.mgmt.storagesync.models.ServerEndpointSyncActivityStatus - :ivar download_activity: Download sync activity. - :vartype download_activity: ~azure.mgmt.storagesync.models.ServerEndpointSyncActivityStatus - :ivar offline_data_transfer_status: Offline Data Transfer State. Possible values include: - "InProgress", "Stopping", "NotRunning", "Complete". - :vartype offline_data_transfer_status: str or - ~azure.mgmt.storagesync.models.ServerEndpointOfflineDataTransferState - :ivar background_data_download_activity: Background data download activity. - :vartype background_data_download_activity: - ~azure.mgmt.storagesync.models.ServerEndpointBackgroundDataDownloadActivity - """ - - _validation = { - 'download_health': {'readonly': True}, - 'upload_health': {'readonly': True}, - 'combined_health': {'readonly': True}, - 'sync_activity': {'readonly': True}, - 'total_persistent_files_not_syncing_count': {'readonly': True, 'minimum': 0}, - 'last_updated_timestamp': {'readonly': True}, - 'upload_status': {'readonly': True}, - 'download_status': {'readonly': True}, - 'upload_activity': {'readonly': True}, - 'download_activity': {'readonly': True}, - 'offline_data_transfer_status': {'readonly': True}, - 'background_data_download_activity': {'readonly': True}, - } - - _attribute_map = { - 'download_health': {'key': 'downloadHealth', 'type': 'str'}, - 'upload_health': {'key': 'uploadHealth', 'type': 'str'}, - 'combined_health': {'key': 'combinedHealth', 'type': 'str'}, - 'sync_activity': {'key': 'syncActivity', 'type': 'str'}, - 'total_persistent_files_not_syncing_count': {'key': 'totalPersistentFilesNotSyncingCount', 'type': 'long'}, - 'last_updated_timestamp': {'key': 'lastUpdatedTimestamp', 'type': 'iso-8601'}, - 'upload_status': {'key': 'uploadStatus', 'type': 'ServerEndpointSyncSessionStatus'}, - 'download_status': {'key': 'downloadStatus', 'type': 'ServerEndpointSyncSessionStatus'}, - 'upload_activity': {'key': 'uploadActivity', 'type': 'ServerEndpointSyncActivityStatus'}, - 'download_activity': {'key': 'downloadActivity', 'type': 'ServerEndpointSyncActivityStatus'}, - 'offline_data_transfer_status': {'key': 'offlineDataTransferStatus', 'type': 'str'}, - 'background_data_download_activity': {'key': 'backgroundDataDownloadActivity', 'type': 'ServerEndpointBackgroundDataDownloadActivity'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerEndpointSyncStatus, self).__init__(**kwargs) - self.download_health = None - self.upload_health = None - self.combined_health = None - self.sync_activity = None - self.total_persistent_files_not_syncing_count = None - self.last_updated_timestamp = None - self.upload_status = None - self.download_status = None - self.upload_activity = None - self.download_activity = None - self.offline_data_transfer_status = None - self.background_data_download_activity = None - - -class ServerEndpointUpdateParameters(msrest.serialization.Model): - """Parameters for updating an Server Endpoint. - - :param cloud_tiering: Cloud Tiering. Possible values include: "on", "off". - :type cloud_tiering: str or ~azure.mgmt.storagesync.models.FeatureStatus - :param volume_free_space_percent: Level of free space to be maintained by Cloud Tiering if it - is enabled. - :type volume_free_space_percent: int - :param tier_files_older_than_days: Tier files older than days. - :type tier_files_older_than_days: int - :param offline_data_transfer: Offline data transfer. Possible values include: "on", "off". - :type offline_data_transfer: str or ~azure.mgmt.storagesync.models.FeatureStatus - :param offline_data_transfer_share_name: Offline data transfer share name. - :type offline_data_transfer_share_name: str - :param local_cache_mode: Policy for enabling follow-the-sun business models: link local cache - to cloud behavior to pre-populate before local access. Possible values include: - "DownloadNewAndModifiedFiles", "UpdateLocallyCachedFiles". - :type local_cache_mode: str or ~azure.mgmt.storagesync.models.LocalCacheMode - """ - - _validation = { - 'volume_free_space_percent': {'maximum': 100, 'minimum': 0}, - 'tier_files_older_than_days': {'maximum': 2147483647, 'minimum': 0}, - } - - _attribute_map = { - 'cloud_tiering': {'key': 'properties.cloudTiering', 'type': 'str'}, - 'volume_free_space_percent': {'key': 'properties.volumeFreeSpacePercent', 'type': 'int'}, - 'tier_files_older_than_days': {'key': 'properties.tierFilesOlderThanDays', 'type': 'int'}, - 'offline_data_transfer': {'key': 'properties.offlineDataTransfer', 'type': 'str'}, - 'offline_data_transfer_share_name': {'key': 'properties.offlineDataTransferShareName', 'type': 'str'}, - 'local_cache_mode': {'key': 'properties.localCacheMode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerEndpointUpdateParameters, self).__init__(**kwargs) - self.cloud_tiering = kwargs.get('cloud_tiering', None) - self.volume_free_space_percent = kwargs.get('volume_free_space_percent', None) - self.tier_files_older_than_days = kwargs.get('tier_files_older_than_days', None) - self.offline_data_transfer = kwargs.get('offline_data_transfer', None) - self.offline_data_transfer_share_name = kwargs.get('offline_data_transfer_share_name', None) - self.local_cache_mode = kwargs.get('local_cache_mode', None) - - -class StorageSyncApiError(msrest.serialization.Model): - """Error type. - - :param code: Error code of the given entry. - :type code: str - :param message: Error message of the given entry. - :type message: str - :param target: Target of the given error entry. - :type target: str - :param details: Error details of the given entry. - :type details: ~azure.mgmt.storagesync.models.StorageSyncErrorDetails - :param inner_error: Inner error details of the given entry. - :type inner_error: ~azure.mgmt.storagesync.models.StorageSyncInnerErrorDetails - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'StorageSyncErrorDetails'}, - 'inner_error': {'key': 'innerError', 'type': 'StorageSyncInnerErrorDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageSyncApiError, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.target = kwargs.get('target', None) - self.details = kwargs.get('details', None) - self.inner_error = kwargs.get('inner_error', None) - - -class StorageSyncError(msrest.serialization.Model): - """Error type. - - :param error: Error details of the given entry. - :type error: ~azure.mgmt.storagesync.models.StorageSyncApiError - :param innererror: Error details of the given entry. - :type innererror: ~azure.mgmt.storagesync.models.StorageSyncApiError - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'StorageSyncApiError'}, - 'innererror': {'key': 'innererror', 'type': 'StorageSyncApiError'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageSyncError, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - self.innererror = kwargs.get('innererror', None) - - -class StorageSyncErrorDetails(msrest.serialization.Model): - """Error Details object. - - :param code: Error code of the given entry. - :type code: str - :param message: Error message of the given entry. - :type message: str - :param target: Target of the given entry. - :type target: str - :param request_uri: Request URI of the given entry. - :type request_uri: str - :param exception_type: Exception type of the given entry. - :type exception_type: str - :param http_method: HTTP method of the given entry. - :type http_method: str - :param hashed_message: Hashed message of the given entry. - :type hashed_message: str - :param http_error_code: HTTP error code of the given entry. - :type http_error_code: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'request_uri': {'key': 'requestUri', 'type': 'str'}, - 'exception_type': {'key': 'exceptionType', 'type': 'str'}, - 'http_method': {'key': 'httpMethod', 'type': 'str'}, - 'hashed_message': {'key': 'hashedMessage', 'type': 'str'}, - 'http_error_code': {'key': 'httpErrorCode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageSyncErrorDetails, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.target = kwargs.get('target', None) - self.request_uri = kwargs.get('request_uri', None) - self.exception_type = kwargs.get('exception_type', None) - self.http_method = kwargs.get('http_method', None) - self.hashed_message = kwargs.get('hashed_message', None) - self.http_error_code = kwargs.get('http_error_code', None) - - -class StorageSyncInnerErrorDetails(msrest.serialization.Model): - """Error Details object. - - :param call_stack: Call stack of the error. - :type call_stack: str - :param message: Error message of the error. - :type message: str - :param inner_exception: Exception of the inner error. - :type inner_exception: str - :param inner_exception_call_stack: Call stack of the inner error. - :type inner_exception_call_stack: str - """ - - _attribute_map = { - 'call_stack': {'key': 'callStack', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'inner_exception': {'key': 'innerException', 'type': 'str'}, - 'inner_exception_call_stack': {'key': 'innerExceptionCallStack', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageSyncInnerErrorDetails, self).__init__(**kwargs) - self.call_stack = kwargs.get('call_stack', None) - self.message = kwargs.get('message', None) - self.inner_exception = kwargs.get('inner_exception', None) - self.inner_exception_call_stack = kwargs.get('inner_exception_call_stack', None) - - -class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.location = kwargs['location'] - - -class StorageSyncService(TrackedResource): - """Storage Sync Service object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param incoming_traffic_policy: Incoming Traffic Policy. Possible values include: - "AllowAllTraffic", "AllowVirtualNetworksOnly". - :type incoming_traffic_policy: str or ~azure.mgmt.storagesync.models.IncomingTrafficPolicy - :ivar storage_sync_service_status: Storage Sync service status. - :vartype storage_sync_service_status: int - :ivar storage_sync_service_uid: Storage Sync service Uid. - :vartype storage_sync_service_uid: str - :ivar provisioning_state: StorageSyncService Provisioning State. - :vartype provisioning_state: str - :ivar last_workflow_id: StorageSyncService lastWorkflowId. - :vartype last_workflow_id: str - :ivar last_operation_name: Resource Last Operation Name. - :vartype last_operation_name: str - :ivar private_endpoint_connections: List of private endpoint connection associated with the - specified storage sync service. - :vartype private_endpoint_connections: - list[~azure.mgmt.storagesync.models.PrivateEndpointConnection] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'storage_sync_service_status': {'readonly': True}, - 'storage_sync_service_uid': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'last_workflow_id': {'readonly': True}, - 'last_operation_name': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'incoming_traffic_policy': {'key': 'properties.incomingTrafficPolicy', 'type': 'str'}, - 'storage_sync_service_status': {'key': 'properties.storageSyncServiceStatus', 'type': 'int'}, - 'storage_sync_service_uid': {'key': 'properties.storageSyncServiceUid', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'last_workflow_id': {'key': 'properties.lastWorkflowId', 'type': 'str'}, - 'last_operation_name': {'key': 'properties.lastOperationName', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageSyncService, self).__init__(**kwargs) - self.incoming_traffic_policy = kwargs.get('incoming_traffic_policy', None) - self.storage_sync_service_status = None - self.storage_sync_service_uid = None - self.provisioning_state = None - self.last_workflow_id = None - self.last_operation_name = None - self.private_endpoint_connections = None - - -class StorageSyncServiceArray(msrest.serialization.Model): - """Array of StorageSyncServices. - - :param value: Collection of StorageSyncServices. - :type value: list[~azure.mgmt.storagesync.models.StorageSyncService] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageSyncService]'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageSyncServiceArray, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class StorageSyncServiceCreateParameters(msrest.serialization.Model): - """The parameters used when creating a storage sync service. - - All required parameters must be populated in order to send to Azure. - - :param location: Required. Required. Gets or sets the location of the resource. This will be - one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. - :type location: str - :param tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used for viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key with a length no - greater than 128 characters and a value with a length no greater than 256 characters. - :type tags: dict[str, str] - :param incoming_traffic_policy: Incoming Traffic Policy. Possible values include: - "AllowAllTraffic", "AllowVirtualNetworksOnly". - :type incoming_traffic_policy: str or ~azure.mgmt.storagesync.models.IncomingTrafficPolicy - """ - - _validation = { - 'location': {'required': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'incoming_traffic_policy': {'key': 'properties.incomingTrafficPolicy', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageSyncServiceCreateParameters, self).__init__(**kwargs) - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - self.incoming_traffic_policy = kwargs.get('incoming_traffic_policy', None) - - -class StorageSyncServiceUpdateParameters(msrest.serialization.Model): - """Parameters for updating an Storage sync service. - - :param tags: A set of tags. The user-specified tags associated with the storage sync service. - :type tags: dict[str, str] - :param incoming_traffic_policy: Incoming Traffic Policy. Possible values include: - "AllowAllTraffic", "AllowVirtualNetworksOnly". - :type incoming_traffic_policy: str or ~azure.mgmt.storagesync.models.IncomingTrafficPolicy - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'incoming_traffic_policy': {'key': 'properties.incomingTrafficPolicy', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageSyncServiceUpdateParameters, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.incoming_traffic_policy = kwargs.get('incoming_traffic_policy', None) - - -class SubscriptionState(msrest.serialization.Model): - """Subscription State object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param state: State of Azure Subscription. Possible values include: "Registered", - "Unregistered", "Warned", "Suspended", "Deleted". - :type state: str or ~azure.mgmt.storagesync.models.Reason - :ivar istransitioning: Is Transitioning. - :vartype istransitioning: bool - :param properties: Subscription state properties. - :type properties: object - """ - - _validation = { - 'istransitioning': {'readonly': True}, - } - - _attribute_map = { - 'state': {'key': 'state', 'type': 'str'}, - 'istransitioning': {'key': 'istransitioning', 'type': 'bool'}, - 'properties': {'key': 'properties', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionState, self).__init__(**kwargs) - self.state = kwargs.get('state', None) - self.istransitioning = None - self.properties = kwargs.get('properties', None) - - -class SyncGroup(ProxyResource): - """Sync Group object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar unique_id: Unique Id. - :vartype unique_id: str - :ivar sync_group_status: Sync group status. - :vartype sync_group_status: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'unique_id': {'readonly': True}, - 'sync_group_status': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'unique_id': {'key': 'properties.uniqueId', 'type': 'str'}, - 'sync_group_status': {'key': 'properties.syncGroupStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SyncGroup, self).__init__(**kwargs) - self.unique_id = None - self.sync_group_status = None - - -class SyncGroupArray(msrest.serialization.Model): - """Array of SyncGroup. - - :param value: Collection of SyncGroup. - :type value: list[~azure.mgmt.storagesync.models.SyncGroup] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SyncGroup]'}, - } - - def __init__( - self, - **kwargs - ): - super(SyncGroupArray, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class SyncGroupCreateParameters(ProxyResource): - """The parameters used when creating a sync group. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param properties: The parameters used to create the sync group. - :type properties: object - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(SyncGroupCreateParameters, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class TriggerChangeDetectionParameters(msrest.serialization.Model): - """The parameters used when calling trigger change detection action on cloud endpoint. - - :param directory_path: Relative path to a directory Azure File share for which change detection - is to be performed. - :type directory_path: str - :param change_detection_mode: Change Detection Mode. Applies to a directory specified in - directoryPath parameter. Possible values include: "Default", "Recursive". - :type change_detection_mode: str or ~azure.mgmt.storagesync.models.ChangeDetectionMode - :param paths: Array of relative paths on the Azure File share to be included in the change - detection. Can be files and directories. - :type paths: list[str] - """ - - _attribute_map = { - 'directory_path': {'key': 'directoryPath', 'type': 'str'}, - 'change_detection_mode': {'key': 'changeDetectionMode', 'type': 'str'}, - 'paths': {'key': 'paths', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(TriggerChangeDetectionParameters, self).__init__(**kwargs) - self.directory_path = kwargs.get('directory_path', None) - self.change_detection_mode = kwargs.get('change_detection_mode', None) - self.paths = kwargs.get('paths', None) - - -class TriggerRolloverRequest(msrest.serialization.Model): - """Trigger Rollover Request. - - :param server_certificate: Certificate Data. - :type server_certificate: str - """ - - _attribute_map = { - 'server_certificate': {'key': 'serverCertificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TriggerRolloverRequest, self).__init__(**kwargs) - self.server_certificate = kwargs.get('server_certificate', None) - - -class Workflow(ProxyResource): - """Workflow resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar last_step_name: last step name. - :vartype last_step_name: str - :ivar status: workflow status. Possible values include: "active", "expired", "succeeded", - "aborted", "failed". - :vartype status: str or ~azure.mgmt.storagesync.models.WorkflowStatus - :ivar operation: operation direction. Possible values include: "do", "undo", "cancel". - :vartype operation: str or ~azure.mgmt.storagesync.models.OperationDirection - :ivar steps: workflow steps. - :vartype steps: str - :ivar last_operation_id: workflow last operation identifier. - :vartype last_operation_id: str - :ivar command_name: workflow command name. - :vartype command_name: str - :ivar created_timestamp: workflow created timestamp. - :vartype created_timestamp: ~datetime.datetime - :ivar last_status_timestamp: workflow last status timestamp. - :vartype last_status_timestamp: ~datetime.datetime - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_step_name': {'readonly': True}, - 'status': {'readonly': True}, - 'operation': {'readonly': True}, - 'steps': {'readonly': True}, - 'last_operation_id': {'readonly': True}, - 'command_name': {'readonly': True}, - 'created_timestamp': {'readonly': True}, - 'last_status_timestamp': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'last_step_name': {'key': 'properties.lastStepName', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'operation': {'key': 'properties.operation', 'type': 'str'}, - 'steps': {'key': 'properties.steps', 'type': 'str'}, - 'last_operation_id': {'key': 'properties.lastOperationId', 'type': 'str'}, - 'command_name': {'key': 'properties.commandName', 'type': 'str'}, - 'created_timestamp': {'key': 'properties.createdTimestamp', 'type': 'iso-8601'}, - 'last_status_timestamp': {'key': 'properties.lastStatusTimestamp', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(Workflow, self).__init__(**kwargs) - self.last_step_name = None - self.status = None - self.operation = None - self.steps = None - self.last_operation_id = None - self.command_name = None - self.created_timestamp = None - self.last_status_timestamp = None - - -class WorkflowArray(msrest.serialization.Model): - """Array of Workflow. - - :param value: Collection of workflow items. - :type value: list[~azure.mgmt.storagesync.models.Workflow] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Workflow]'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkflowArray, self).__init__(**kwargs) - self.value = kwargs.get('value', None) diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/models/_models_py3.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/models/_models_py3.py index 37514c302f29..b067ff2b691a 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/models/_models_py3.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, Union from azure.core.exceptions import HttpResponseError import msrest.serialization @@ -17,8 +17,8 @@ class BackupRequest(msrest.serialization.Model): """Backup request. - :param azure_file_share: Azure File Share. - :type azure_file_share: str + :ivar azure_file_share: Azure File Share. + :vartype azure_file_share: str """ _attribute_map = { @@ -31,6 +31,10 @@ def __init__( azure_file_share: Optional[str] = None, **kwargs ): + """ + :keyword azure_file_share: Azure File Share. + :paramtype azure_file_share: str + """ super(BackupRequest, self).__init__(**kwargs) self.azure_file_share = azure_file_share @@ -42,11 +46,10 @@ class CheckNameAvailabilityParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name to check for availability. - :type name: str - :ivar type: Required. The resource type. Must be set to - Microsoft.StorageSync/storageSyncServices. Default value: - "Microsoft.StorageSync/storageSyncServices". + :ivar name: Required. The name to check for availability. + :vartype name: str + :ivar type: The resource type. Must be set to Microsoft.StorageSync/storageSyncServices. Has + constant value: "Microsoft.StorageSync/storageSyncServices". :vartype type: str """ @@ -68,6 +71,10 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. The name to check for availability. + :paramtype name: str + """ super(CheckNameAvailabilityParameters, self).__init__(**kwargs) self.name = name @@ -105,6 +112,8 @@ def __init__( self, **kwargs ): + """ + """ super(CheckNameAvailabilityResult, self).__init__(**kwargs) self.name_available = None self.reason = None @@ -142,6 +151,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -179,6 +190,8 @@ def __init__( self, **kwargs ): + """ + """ super(ProxyResource, self).__init__(**kwargs) @@ -195,24 +208,27 @@ class CloudEndpoint(ProxyResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param storage_account_resource_id: Storage Account Resource Id. - :type storage_account_resource_id: str - :param azure_file_share_name: Azure file share name. - :type azure_file_share_name: str - :param storage_account_tenant_id: Storage Account Tenant Id. - :type storage_account_tenant_id: str - :param partnership_id: Partnership Id. - :type partnership_id: str - :param friendly_name: Friendly Name. - :type friendly_name: str + :ivar storage_account_resource_id: Storage Account Resource Id. + :vartype storage_account_resource_id: str + :ivar azure_file_share_name: Azure file share name. + :vartype azure_file_share_name: str + :ivar storage_account_tenant_id: Storage Account Tenant Id. + :vartype storage_account_tenant_id: str + :ivar partnership_id: Partnership Id. + :vartype partnership_id: str + :ivar friendly_name: Friendly Name. + :vartype friendly_name: str :ivar backup_enabled: Backup Enabled. :vartype backup_enabled: str - :param provisioning_state: CloudEndpoint Provisioning State. - :type provisioning_state: str - :param last_workflow_id: CloudEndpoint lastWorkflowId. - :type last_workflow_id: str - :param last_operation_name: Resource Last Operation Name. - :type last_operation_name: str + :ivar provisioning_state: CloudEndpoint Provisioning State. + :vartype provisioning_state: str + :ivar last_workflow_id: CloudEndpoint lastWorkflowId. + :vartype last_workflow_id: str + :ivar last_operation_name: Resource Last Operation Name. + :vartype last_operation_name: str + :ivar change_enumeration_status: Cloud endpoint change enumeration status. + :vartype change_enumeration_status: + ~azure.mgmt.storagesync.models.CloudEndpointChangeEnumerationStatus """ _validation = { @@ -220,6 +236,7 @@ class CloudEndpoint(ProxyResource): 'name': {'readonly': True}, 'type': {'readonly': True}, 'backup_enabled': {'readonly': True}, + 'change_enumeration_status': {'readonly': True}, } _attribute_map = { @@ -235,6 +252,7 @@ class CloudEndpoint(ProxyResource): 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, 'last_workflow_id': {'key': 'properties.lastWorkflowId', 'type': 'str'}, 'last_operation_name': {'key': 'properties.lastOperationName', 'type': 'str'}, + 'change_enumeration_status': {'key': 'properties.changeEnumerationStatus', 'type': 'CloudEndpointChangeEnumerationStatus'}, } def __init__( @@ -250,6 +268,24 @@ def __init__( last_operation_name: Optional[str] = None, **kwargs ): + """ + :keyword storage_account_resource_id: Storage Account Resource Id. + :paramtype storage_account_resource_id: str + :keyword azure_file_share_name: Azure file share name. + :paramtype azure_file_share_name: str + :keyword storage_account_tenant_id: Storage Account Tenant Id. + :paramtype storage_account_tenant_id: str + :keyword partnership_id: Partnership Id. + :paramtype partnership_id: str + :keyword friendly_name: Friendly Name. + :paramtype friendly_name: str + :keyword provisioning_state: CloudEndpoint Provisioning State. + :paramtype provisioning_state: str + :keyword last_workflow_id: CloudEndpoint lastWorkflowId. + :paramtype last_workflow_id: str + :keyword last_operation_name: Resource Last Operation Name. + :paramtype last_operation_name: str + """ super(CloudEndpoint, self).__init__(**kwargs) self.storage_account_resource_id = storage_account_resource_id self.azure_file_share_name = azure_file_share_name @@ -260,13 +296,14 @@ def __init__( self.provisioning_state = provisioning_state self.last_workflow_id = last_workflow_id self.last_operation_name = last_operation_name + self.change_enumeration_status = None class CloudEndpointArray(msrest.serialization.Model): """Array of CloudEndpoint. - :param value: Collection of CloudEndpoint. - :type value: list[~azure.mgmt.storagesync.models.CloudEndpoint] + :ivar value: Collection of CloudEndpoint. + :vartype value: list[~azure.mgmt.storagesync.models.CloudEndpoint] """ _attribute_map = { @@ -279,10 +316,145 @@ def __init__( value: Optional[List["CloudEndpoint"]] = None, **kwargs ): + """ + :keyword value: Collection of CloudEndpoint. + :paramtype value: list[~azure.mgmt.storagesync.models.CloudEndpoint] + """ super(CloudEndpointArray, self).__init__(**kwargs) self.value = value +class CloudEndpointChangeEnumerationActivity(msrest.serialization.Model): + """Cloud endpoint change enumeration activity object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar last_updated_timestamp: Last updated timestamp. + :vartype last_updated_timestamp: ~datetime.datetime + :ivar operation_state: Change enumeration operation state. Possible values include: + "InitialEnumerationInProgress", "EnumerationInProgress". + :vartype operation_state: str or + ~azure.mgmt.storagesync.models.CloudEndpointChangeEnumerationActivityState + :ivar status_code: When non-zero, indicates an issue that is delaying change enumeration. + :vartype status_code: int + :ivar started_timestamp: Timestamp when change enumeration started. + :vartype started_timestamp: ~datetime.datetime + :ivar processed_files_count: Count of files processed. + :vartype processed_files_count: long + :ivar processed_directories_count: Count of directories processed. + :vartype processed_directories_count: long + :ivar total_files_count: Total count of files enumerated. + :vartype total_files_count: long + :ivar total_directories_count: Total count of directories enumerated. + :vartype total_directories_count: long + :ivar total_size_bytes: Total enumerated size in bytes. + :vartype total_size_bytes: long + :ivar progress_percent: Progress percentage for change enumeration run, excluding processing of + deletes. + :vartype progress_percent: int + :ivar minutes_remaining: Estimate of time remaining for the enumeration run. + :vartype minutes_remaining: int + :ivar total_counts_state: Change enumeration total counts state. Possible values include: + "Calculating", "Final". + :vartype total_counts_state: str or + ~azure.mgmt.storagesync.models.CloudEndpointChangeEnumerationTotalCountsState + :ivar deletes_progress_percent: Progress percentage for processing deletes. This is done + separately from the rest of the enumeration run. + :vartype deletes_progress_percent: int + """ + + _validation = { + 'last_updated_timestamp': {'readonly': True}, + 'operation_state': {'readonly': True}, + 'status_code': {'readonly': True}, + 'started_timestamp': {'readonly': True}, + 'processed_files_count': {'readonly': True, 'minimum': 0}, + 'processed_directories_count': {'readonly': True, 'minimum': 0}, + 'total_files_count': {'readonly': True, 'minimum': 0}, + 'total_directories_count': {'readonly': True, 'minimum': 0}, + 'total_size_bytes': {'readonly': True, 'minimum': 0}, + 'progress_percent': {'readonly': True, 'maximum': 100, 'minimum': 0}, + 'minutes_remaining': {'readonly': True, 'minimum': 0}, + 'total_counts_state': {'readonly': True}, + 'deletes_progress_percent': {'readonly': True, 'maximum': 100, 'minimum': 0}, + } + + _attribute_map = { + 'last_updated_timestamp': {'key': 'lastUpdatedTimestamp', 'type': 'iso-8601'}, + 'operation_state': {'key': 'operationState', 'type': 'str'}, + 'status_code': {'key': 'statusCode', 'type': 'int'}, + 'started_timestamp': {'key': 'startedTimestamp', 'type': 'iso-8601'}, + 'processed_files_count': {'key': 'processedFilesCount', 'type': 'long'}, + 'processed_directories_count': {'key': 'processedDirectoriesCount', 'type': 'long'}, + 'total_files_count': {'key': 'totalFilesCount', 'type': 'long'}, + 'total_directories_count': {'key': 'totalDirectoriesCount', 'type': 'long'}, + 'total_size_bytes': {'key': 'totalSizeBytes', 'type': 'long'}, + 'progress_percent': {'key': 'progressPercent', 'type': 'int'}, + 'minutes_remaining': {'key': 'minutesRemaining', 'type': 'int'}, + 'total_counts_state': {'key': 'totalCountsState', 'type': 'str'}, + 'deletes_progress_percent': {'key': 'deletesProgressPercent', 'type': 'int'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(CloudEndpointChangeEnumerationActivity, self).__init__(**kwargs) + self.last_updated_timestamp = None + self.operation_state = None + self.status_code = None + self.started_timestamp = None + self.processed_files_count = None + self.processed_directories_count = None + self.total_files_count = None + self.total_directories_count = None + self.total_size_bytes = None + self.progress_percent = None + self.minutes_remaining = None + self.total_counts_state = None + self.deletes_progress_percent = None + + +class CloudEndpointChangeEnumerationStatus(msrest.serialization.Model): + """Cloud endpoint change enumeration status object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar last_updated_timestamp: Last updated timestamp. + :vartype last_updated_timestamp: ~datetime.datetime + :ivar last_enumeration_status: Status of last completed change enumeration. + :vartype last_enumeration_status: + ~azure.mgmt.storagesync.models.CloudEndpointLastChangeEnumerationStatus + :ivar activity: Change enumeration activity. + :vartype activity: ~azure.mgmt.storagesync.models.CloudEndpointChangeEnumerationActivity + """ + + _validation = { + 'last_updated_timestamp': {'readonly': True}, + 'last_enumeration_status': {'readonly': True}, + 'activity': {'readonly': True}, + } + + _attribute_map = { + 'last_updated_timestamp': {'key': 'lastUpdatedTimestamp', 'type': 'iso-8601'}, + 'last_enumeration_status': {'key': 'lastEnumerationStatus', 'type': 'CloudEndpointLastChangeEnumerationStatus'}, + 'activity': {'key': 'activity', 'type': 'CloudEndpointChangeEnumerationActivity'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(CloudEndpointChangeEnumerationStatus, self).__init__(**kwargs) + self.last_updated_timestamp = None + self.last_enumeration_status = None + self.activity = None + + class CloudEndpointCreateParameters(ProxyResource): """The parameters used when creating a cloud endpoint. @@ -296,14 +468,14 @@ class CloudEndpointCreateParameters(ProxyResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param storage_account_resource_id: Storage Account Resource Id. - :type storage_account_resource_id: str - :param azure_file_share_name: Azure file share name. - :type azure_file_share_name: str - :param storage_account_tenant_id: Storage Account Tenant Id. - :type storage_account_tenant_id: str - :param friendly_name: Friendly Name. - :type friendly_name: str + :ivar storage_account_resource_id: Storage Account Resource Id. + :vartype storage_account_resource_id: str + :ivar azure_file_share_name: Azure file share name. + :vartype azure_file_share_name: str + :ivar storage_account_tenant_id: Storage Account Tenant Id. + :vartype storage_account_tenant_id: str + :ivar friendly_name: Friendly Name. + :vartype friendly_name: str """ _validation = { @@ -331,6 +503,16 @@ def __init__( friendly_name: Optional[str] = None, **kwargs ): + """ + :keyword storage_account_resource_id: Storage Account Resource Id. + :paramtype storage_account_resource_id: str + :keyword azure_file_share_name: Azure file share name. + :paramtype azure_file_share_name: str + :keyword storage_account_tenant_id: Storage Account Tenant Id. + :paramtype storage_account_tenant_id: str + :keyword friendly_name: Friendly Name. + :paramtype friendly_name: str + """ super(CloudEndpointCreateParameters, self).__init__(**kwargs) self.storage_account_resource_id = storage_account_resource_id self.azure_file_share_name = azure_file_share_name @@ -338,6 +520,58 @@ def __init__( self.friendly_name = friendly_name +class CloudEndpointLastChangeEnumerationStatus(msrest.serialization.Model): + """Cloud endpoint change enumeration status object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar started_timestamp: Timestamp when change enumeration started. + :vartype started_timestamp: ~datetime.datetime + :ivar completed_timestamp: Timestamp when change enumeration completed. + :vartype completed_timestamp: ~datetime.datetime + :ivar namespace_files_count: Count of files in the namespace. + :vartype namespace_files_count: long + :ivar namespace_directories_count: Count of directories in the namespace. + :vartype namespace_directories_count: long + :ivar namespace_size_bytes: Namespace size in bytes. + :vartype namespace_size_bytes: long + :ivar next_run_timestamp: Timestamp of when change enumeration is expected to run again. + :vartype next_run_timestamp: ~datetime.datetime + """ + + _validation = { + 'started_timestamp': {'readonly': True}, + 'completed_timestamp': {'readonly': True}, + 'namespace_files_count': {'readonly': True, 'minimum': 0}, + 'namespace_directories_count': {'readonly': True, 'minimum': 0}, + 'namespace_size_bytes': {'readonly': True, 'minimum': 0}, + 'next_run_timestamp': {'readonly': True}, + } + + _attribute_map = { + 'started_timestamp': {'key': 'startedTimestamp', 'type': 'iso-8601'}, + 'completed_timestamp': {'key': 'completedTimestamp', 'type': 'iso-8601'}, + 'namespace_files_count': {'key': 'namespaceFilesCount', 'type': 'long'}, + 'namespace_directories_count': {'key': 'namespaceDirectoriesCount', 'type': 'long'}, + 'namespace_size_bytes': {'key': 'namespaceSizeBytes', 'type': 'long'}, + 'next_run_timestamp': {'key': 'nextRunTimestamp', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(CloudEndpointLastChangeEnumerationStatus, self).__init__(**kwargs) + self.started_timestamp = None + self.completed_timestamp = None + self.namespace_files_count = None + self.namespace_directories_count = None + self.namespace_size_bytes = None + self.next_run_timestamp = None + + class CloudTieringCachePerformance(msrest.serialization.Model): """Server endpoint cloud tiering status object. @@ -372,6 +606,8 @@ def __init__( self, **kwargs ): + """ + """ super(CloudTieringCachePerformance, self).__init__(**kwargs) self.last_updated_timestamp = None self.cache_hit_bytes = None @@ -404,6 +640,8 @@ def __init__( self, **kwargs ): + """ + """ super(CloudTieringDatePolicyStatus, self).__init__(**kwargs) self.last_updated_timestamp = None self.tiered_files_most_recent_access_timestamp = None @@ -438,6 +676,8 @@ def __init__( self, **kwargs ): + """ + """ super(CloudTieringFilesNotTiering, self).__init__(**kwargs) self.last_updated_timestamp = None self.total_file_count = None @@ -485,6 +725,8 @@ def __init__( self, **kwargs ): + """ + """ super(CloudTieringSpaceSavings, self).__init__(**kwargs) self.last_updated_timestamp = None self.volume_size_bytes = None @@ -524,6 +766,8 @@ def __init__( self, **kwargs ): + """ + """ super(CloudTieringVolumeFreeSpacePolicyStatus, self).__init__(**kwargs) self.last_updated_timestamp = None self.effective_volume_free_space_policy = None @@ -555,22 +799,81 @@ def __init__( self, **kwargs ): + """ + """ super(FilesNotTieringError, self).__init__(**kwargs) self.error_code = None self.file_count = None +class LocationOperationStatus(msrest.serialization.Model): + """Operation status object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Operation resource Id. + :vartype id: str + :ivar name: Operation Id. + :vartype name: str + :ivar status: Operation status. + :vartype status: str + :ivar start_time: Start time of the operation. + :vartype start_time: ~datetime.datetime + :ivar end_time: End time of the operation. + :vartype end_time: ~datetime.datetime + :ivar error: Error details. + :vartype error: ~azure.mgmt.storagesync.models.StorageSyncApiError + :ivar percent_complete: Percent complete. + :vartype percent_complete: int + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'status': {'readonly': True}, + 'start_time': {'readonly': True}, + 'end_time': {'readonly': True}, + 'error': {'readonly': True}, + 'percent_complete': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, + 'error': {'key': 'error', 'type': 'StorageSyncApiError'}, + 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(LocationOperationStatus, self).__init__(**kwargs) + self.id = None + self.name = None + self.status = None + self.start_time = None + self.end_time = None + self.error = None + self.percent_complete = None + + class OperationDisplayInfo(msrest.serialization.Model): """The operation supported by storage sync. - :param description: The description of the operation. - :type description: str - :param operation: The action that users can perform, based on their permission level. - :type operation: str - :param provider: Service provider: Microsoft StorageSync. - :type provider: str - :param resource: Resource on which the operation is performed. - :type resource: str + :ivar description: The description of the operation. + :vartype description: str + :ivar operation: The action that users can perform, based on their permission level. + :vartype operation: str + :ivar provider: Service provider: Microsoft StorageSync. + :vartype provider: str + :ivar resource: Resource on which the operation is performed. + :vartype resource: str """ _attribute_map = { @@ -589,6 +892,16 @@ def __init__( resource: Optional[str] = None, **kwargs ): + """ + :keyword description: The description of the operation. + :paramtype description: str + :keyword operation: The action that users can perform, based on their permission level. + :paramtype operation: str + :keyword provider: Service provider: Microsoft StorageSync. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed. + :paramtype resource: str + """ super(OperationDisplayInfo, self).__init__(**kwargs) self.description = description self.operation = operation @@ -599,14 +912,14 @@ def __init__( class OperationDisplayResource(msrest.serialization.Model): """Operation Display Resource object. - :param provider: Operation Display Resource Provider. - :type provider: str - :param resource: Operation Display Resource. - :type resource: str - :param operation: Operation Display Resource Operation. - :type operation: str - :param description: Operation Display Resource Description. - :type description: str + :ivar provider: Operation Display Resource Provider. + :vartype provider: str + :ivar resource: Operation Display Resource. + :vartype resource: str + :ivar operation: Operation Display Resource Operation. + :vartype operation: str + :ivar description: Operation Display Resource Description. + :vartype description: str """ _attribute_map = { @@ -625,6 +938,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Operation Display Resource Provider. + :paramtype provider: str + :keyword resource: Operation Display Resource. + :paramtype resource: str + :keyword operation: Operation Display Resource Operation. + :paramtype operation: str + :keyword description: Operation Display Resource Description. + :paramtype description: str + """ super(OperationDisplayResource, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -635,14 +958,14 @@ def __init__( class OperationEntity(msrest.serialization.Model): """The operation supported by storage sync. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The operation supported by storage sync. - :type display: ~azure.mgmt.storagesync.models.OperationDisplayInfo - :param origin: The origin. - :type origin: str - :param properties: Properties of the operations resource. - :type properties: ~azure.mgmt.storagesync.models.OperationProperties + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The operation supported by storage sync. + :vartype display: ~azure.mgmt.storagesync.models.OperationDisplayInfo + :ivar origin: The origin. + :vartype origin: str + :ivar properties: Properties of the operations resource. + :vartype properties: ~azure.mgmt.storagesync.models.OperationProperties """ _attribute_map = { @@ -661,6 +984,16 @@ def __init__( properties: Optional["OperationProperties"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The operation supported by storage sync. + :paramtype display: ~azure.mgmt.storagesync.models.OperationDisplayInfo + :keyword origin: The origin. + :paramtype origin: str + :keyword properties: Properties of the operations resource. + :paramtype properties: ~azure.mgmt.storagesync.models.OperationProperties + """ super(OperationEntity, self).__init__(**kwargs) self.name = name self.display = display @@ -671,10 +1004,10 @@ def __init__( class OperationEntityListResult(msrest.serialization.Model): """The list of storage sync operations. - :param next_link: The link used to get the next page of operations. - :type next_link: str - :param value: The list of operations. - :type value: list[~azure.mgmt.storagesync.models.OperationEntity] + :ivar next_link: The link used to get the next page of operations. + :vartype next_link: str + :ivar value: The list of operations. + :vartype value: list[~azure.mgmt.storagesync.models.OperationEntity] """ _attribute_map = { @@ -689,6 +1022,12 @@ def __init__( value: Optional[List["OperationEntity"]] = None, **kwargs ): + """ + :keyword next_link: The link used to get the next page of operations. + :paramtype next_link: str + :keyword value: The list of operations. + :paramtype value: list[~azure.mgmt.storagesync.models.OperationEntity] + """ super(OperationEntityListResult, self).__init__(**kwargs) self.next_link = next_link self.value = value @@ -697,8 +1036,8 @@ def __init__( class OperationProperties(msrest.serialization.Model): """Properties of the operations resource. - :param service_specification: Service specification for the operations resource. - :type service_specification: + :ivar service_specification: Service specification for the operations resource. + :vartype service_specification: ~azure.mgmt.storagesync.models.OperationResourceServiceSpecification """ @@ -712,6 +1051,11 @@ def __init__( service_specification: Optional["OperationResourceServiceSpecification"] = None, **kwargs ): + """ + :keyword service_specification: Service specification for the operations resource. + :paramtype service_specification: + ~azure.mgmt.storagesync.models.OperationResourceServiceSpecification + """ super(OperationProperties, self).__init__(**kwargs) self.service_specification = service_specification @@ -719,20 +1063,20 @@ def __init__( class OperationResourceMetricSpecification(msrest.serialization.Model): """Operation Display Resource object. - :param name: Name of the metric. - :type name: str - :param display_name: Display name for the metric. - :type display_name: str - :param display_description: Display description for the metric. - :type display_description: str - :param unit: Unit for the metric. - :type unit: str - :param aggregation_type: Aggregation type for the metric. - :type aggregation_type: str - :param fill_gap_with_zero: Fill gaps in the metric with zero. - :type fill_gap_with_zero: bool - :param dimensions: Dimensions for the metric specification. - :type dimensions: + :ivar name: Name of the metric. + :vartype name: str + :ivar display_name: Display name for the metric. + :vartype display_name: str + :ivar display_description: Display description for the metric. + :vartype display_description: str + :ivar unit: Unit for the metric. + :vartype unit: str + :ivar aggregation_type: Aggregation type for the metric. + :vartype aggregation_type: str + :ivar fill_gap_with_zero: Fill gaps in the metric with zero. + :vartype fill_gap_with_zero: bool + :ivar dimensions: Dimensions for the metric specification. + :vartype dimensions: list[~azure.mgmt.storagesync.models.OperationResourceMetricSpecificationDimension] """ @@ -758,6 +1102,23 @@ def __init__( dimensions: Optional[List["OperationResourceMetricSpecificationDimension"]] = None, **kwargs ): + """ + :keyword name: Name of the metric. + :paramtype name: str + :keyword display_name: Display name for the metric. + :paramtype display_name: str + :keyword display_description: Display description for the metric. + :paramtype display_description: str + :keyword unit: Unit for the metric. + :paramtype unit: str + :keyword aggregation_type: Aggregation type for the metric. + :paramtype aggregation_type: str + :keyword fill_gap_with_zero: Fill gaps in the metric with zero. + :paramtype fill_gap_with_zero: bool + :keyword dimensions: Dimensions for the metric specification. + :paramtype dimensions: + list[~azure.mgmt.storagesync.models.OperationResourceMetricSpecificationDimension] + """ super(OperationResourceMetricSpecification, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -771,12 +1132,12 @@ def __init__( class OperationResourceMetricSpecificationDimension(msrest.serialization.Model): """OperationResourceMetricSpecificationDimension object. - :param name: Name of the dimension. - :type name: str - :param display_name: Display name of the dimensions. - :type display_name: str - :param to_be_exported_for_shoebox: Indicates metric should be exported for Shoebox. - :type to_be_exported_for_shoebox: bool + :ivar name: Name of the dimension. + :vartype name: str + :ivar display_name: Display name of the dimensions. + :vartype display_name: str + :ivar to_be_exported_for_shoebox: Indicates metric should be exported for Shoebox. + :vartype to_be_exported_for_shoebox: bool """ _attribute_map = { @@ -793,6 +1154,14 @@ def __init__( to_be_exported_for_shoebox: Optional[bool] = None, **kwargs ): + """ + :keyword name: Name of the dimension. + :paramtype name: str + :keyword display_name: Display name of the dimensions. + :paramtype display_name: str + :keyword to_be_exported_for_shoebox: Indicates metric should be exported for Shoebox. + :paramtype to_be_exported_for_shoebox: bool + """ super(OperationResourceMetricSpecificationDimension, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -802,8 +1171,8 @@ def __init__( class OperationResourceServiceSpecification(msrest.serialization.Model): """Service specification. - :param metric_specifications: List of metric specifications. - :type metric_specifications: + :ivar metric_specifications: List of metric specifications. + :vartype metric_specifications: list[~azure.mgmt.storagesync.models.OperationResourceMetricSpecification] """ @@ -817,6 +1186,11 @@ def __init__( metric_specifications: Optional[List["OperationResourceMetricSpecification"]] = None, **kwargs ): + """ + :keyword metric_specifications: List of metric specifications. + :paramtype metric_specifications: + list[~azure.mgmt.storagesync.models.OperationResourceMetricSpecification] + """ super(OperationResourceServiceSpecification, self).__init__(**kwargs) self.metric_specifications = metric_specifications @@ -858,6 +1232,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationStatus, self).__init__(**kwargs) self.name = None self.status = None @@ -887,6 +1263,8 @@ def __init__( self, **kwargs ): + """ + """ super(PostBackupResponse, self).__init__(**kwargs) self.cloud_endpoint_name = None @@ -894,22 +1272,22 @@ def __init__( class PostRestoreRequest(msrest.serialization.Model): """Post Restore Request. - :param partition: Post Restore partition. - :type partition: str - :param replica_group: Post Restore replica group. - :type replica_group: str - :param request_id: Post Restore request id. - :type request_id: str - :param azure_file_share_uri: Post Restore Azure file share uri. - :type azure_file_share_uri: str - :param status: Post Restore Azure status. - :type status: str - :param source_azure_file_share_uri: Post Restore Azure source azure file share uri. - :type source_azure_file_share_uri: str - :param failed_file_list: Post Restore Azure failed file list. - :type failed_file_list: str - :param restore_file_spec: Post Restore restore file spec array. - :type restore_file_spec: list[~azure.mgmt.storagesync.models.RestoreFileSpec] + :ivar partition: Post Restore partition. + :vartype partition: str + :ivar replica_group: Post Restore replica group. + :vartype replica_group: str + :ivar request_id: Post Restore request id. + :vartype request_id: str + :ivar azure_file_share_uri: Post Restore Azure file share uri. + :vartype azure_file_share_uri: str + :ivar status: Post Restore Azure status. + :vartype status: str + :ivar source_azure_file_share_uri: Post Restore Azure source azure file share uri. + :vartype source_azure_file_share_uri: str + :ivar failed_file_list: Post Restore Azure failed file list. + :vartype failed_file_list: str + :ivar restore_file_spec: Post Restore restore file spec array. + :vartype restore_file_spec: list[~azure.mgmt.storagesync.models.RestoreFileSpec] """ _attribute_map = { @@ -936,6 +1314,24 @@ def __init__( restore_file_spec: Optional[List["RestoreFileSpec"]] = None, **kwargs ): + """ + :keyword partition: Post Restore partition. + :paramtype partition: str + :keyword replica_group: Post Restore replica group. + :paramtype replica_group: str + :keyword request_id: Post Restore request id. + :paramtype request_id: str + :keyword azure_file_share_uri: Post Restore Azure file share uri. + :paramtype azure_file_share_uri: str + :keyword status: Post Restore Azure status. + :paramtype status: str + :keyword source_azure_file_share_uri: Post Restore Azure source azure file share uri. + :paramtype source_azure_file_share_uri: str + :keyword failed_file_list: Post Restore Azure failed file list. + :paramtype failed_file_list: str + :keyword restore_file_spec: Post Restore restore file spec array. + :paramtype restore_file_spec: list[~azure.mgmt.storagesync.models.RestoreFileSpec] + """ super(PostRestoreRequest, self).__init__(**kwargs) self.partition = partition self.replica_group = replica_group @@ -950,25 +1346,25 @@ def __init__( class PreRestoreRequest(msrest.serialization.Model): """Pre Restore request object. - :param partition: Pre Restore partition. - :type partition: str - :param replica_group: Pre Restore replica group. - :type replica_group: str - :param request_id: Pre Restore request id. - :type request_id: str - :param azure_file_share_uri: Pre Restore Azure file share uri. - :type azure_file_share_uri: str - :param status: Pre Restore Azure status. - :type status: str - :param source_azure_file_share_uri: Pre Restore Azure source azure file share uri. - :type source_azure_file_share_uri: str - :param backup_metadata_property_bag: Pre Restore backup metadata property bag. - :type backup_metadata_property_bag: str - :param restore_file_spec: Pre Restore restore file spec array. - :type restore_file_spec: list[~azure.mgmt.storagesync.models.RestoreFileSpec] - :param pause_wait_for_sync_drain_time_period_in_seconds: Pre Restore pause wait for sync drain + :ivar partition: Pre Restore partition. + :vartype partition: str + :ivar replica_group: Pre Restore replica group. + :vartype replica_group: str + :ivar request_id: Pre Restore request id. + :vartype request_id: str + :ivar azure_file_share_uri: Pre Restore Azure file share uri. + :vartype azure_file_share_uri: str + :ivar status: Pre Restore Azure status. + :vartype status: str + :ivar source_azure_file_share_uri: Pre Restore Azure source azure file share uri. + :vartype source_azure_file_share_uri: str + :ivar backup_metadata_property_bag: Pre Restore backup metadata property bag. + :vartype backup_metadata_property_bag: str + :ivar restore_file_spec: Pre Restore restore file spec array. + :vartype restore_file_spec: list[~azure.mgmt.storagesync.models.RestoreFileSpec] + :ivar pause_wait_for_sync_drain_time_period_in_seconds: Pre Restore pause wait for sync drain time period in seconds. - :type pause_wait_for_sync_drain_time_period_in_seconds: int + :vartype pause_wait_for_sync_drain_time_period_in_seconds: int """ _attribute_map = { @@ -997,6 +1393,27 @@ def __init__( pause_wait_for_sync_drain_time_period_in_seconds: Optional[int] = None, **kwargs ): + """ + :keyword partition: Pre Restore partition. + :paramtype partition: str + :keyword replica_group: Pre Restore replica group. + :paramtype replica_group: str + :keyword request_id: Pre Restore request id. + :paramtype request_id: str + :keyword azure_file_share_uri: Pre Restore Azure file share uri. + :paramtype azure_file_share_uri: str + :keyword status: Pre Restore Azure status. + :paramtype status: str + :keyword source_azure_file_share_uri: Pre Restore Azure source azure file share uri. + :paramtype source_azure_file_share_uri: str + :keyword backup_metadata_property_bag: Pre Restore backup metadata property bag. + :paramtype backup_metadata_property_bag: str + :keyword restore_file_spec: Pre Restore restore file spec array. + :paramtype restore_file_spec: list[~azure.mgmt.storagesync.models.RestoreFileSpec] + :keyword pause_wait_for_sync_drain_time_period_in_seconds: Pre Restore pause wait for sync + drain time period in seconds. + :paramtype pause_wait_for_sync_drain_time_period_in_seconds: int + """ super(PreRestoreRequest, self).__init__(**kwargs) self.partition = partition self.replica_group = replica_group @@ -1030,6 +1447,8 @@ def __init__( self, **kwargs ): + """ + """ super(PrivateEndpoint, self).__init__(**kwargs) self.id = None @@ -1047,11 +1466,11 @@ class PrivateEndpointConnection(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param private_endpoint: The resource of private end point. - :type private_endpoint: ~azure.mgmt.storagesync.models.PrivateEndpoint - :param private_link_service_connection_state: A collection of information about the state of - the connection between service consumer and provider. - :type private_link_service_connection_state: + :ivar private_endpoint: The resource of private end point. + :vartype private_endpoint: ~azure.mgmt.storagesync.models.PrivateEndpoint + :ivar private_link_service_connection_state: A collection of information about the state of the + connection between service consumer and provider. + :vartype private_link_service_connection_state: ~azure.mgmt.storagesync.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. Possible values include: "Succeeded", "Creating", "Deleting", "Failed". @@ -1082,6 +1501,14 @@ def __init__( private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, **kwargs ): + """ + :keyword private_endpoint: The resource of private end point. + :paramtype private_endpoint: ~azure.mgmt.storagesync.models.PrivateEndpoint + :keyword private_link_service_connection_state: A collection of information about the state of + the connection between service consumer and provider. + :paramtype private_link_service_connection_state: + ~azure.mgmt.storagesync.models.PrivateLinkServiceConnectionState + """ super(PrivateEndpointConnection, self).__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state @@ -1091,8 +1518,8 @@ def __init__( class PrivateEndpointConnectionListResult(msrest.serialization.Model): """List of private endpoint connection associated with the specified storage account. - :param value: Array of private endpoint connections. - :type value: list[~azure.mgmt.storagesync.models.PrivateEndpointConnection] + :ivar value: Array of private endpoint connections. + :vartype value: list[~azure.mgmt.storagesync.models.PrivateEndpointConnection] """ _attribute_map = { @@ -1105,6 +1532,10 @@ def __init__( value: Optional[List["PrivateEndpointConnection"]] = None, **kwargs ): + """ + :keyword value: Array of private endpoint connections. + :paramtype value: list[~azure.mgmt.storagesync.models.PrivateEndpointConnection] + """ super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) self.value = value @@ -1126,8 +1557,8 @@ class PrivateLinkResource(Resource): :vartype group_id: str :ivar required_members: The private link resource required member names. :vartype required_members: list[str] - :param required_zone_names: The private link resource Private link DNS zone name. - :type required_zone_names: list[str] + :ivar required_zone_names: The private link resource Private link DNS zone name. + :vartype required_zone_names: list[str] """ _validation = { @@ -1153,6 +1584,10 @@ def __init__( required_zone_names: Optional[List[str]] = None, **kwargs ): + """ + :keyword required_zone_names: The private link resource Private link DNS zone name. + :paramtype required_zone_names: list[str] + """ super(PrivateLinkResource, self).__init__(**kwargs) self.group_id = None self.required_members = None @@ -1162,8 +1597,8 @@ def __init__( class PrivateLinkResourceListResult(msrest.serialization.Model): """A list of private link resources. - :param value: Array of private link resources. - :type value: list[~azure.mgmt.storagesync.models.PrivateLinkResource] + :ivar value: Array of private link resources. + :vartype value: list[~azure.mgmt.storagesync.models.PrivateLinkResource] """ _attribute_map = { @@ -1176,6 +1611,10 @@ def __init__( value: Optional[List["PrivateLinkResource"]] = None, **kwargs ): + """ + :keyword value: Array of private link resources. + :paramtype value: list[~azure.mgmt.storagesync.models.PrivateLinkResource] + """ super(PrivateLinkResourceListResult, self).__init__(**kwargs) self.value = value @@ -1183,14 +1622,14 @@ def __init__( class PrivateLinkServiceConnectionState(msrest.serialization.Model): """A collection of information about the state of the connection between service consumer and provider. - :param status: Indicates whether the connection has been Approved/Rejected/Removed by the owner + :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. Possible values include: "Pending", "Approved", "Rejected". - :type status: str or ~azure.mgmt.storagesync.models.PrivateEndpointServiceConnectionStatus - :param description: The reason for approval/rejection of the connection. - :type description: str - :param actions_required: A message indicating if changes on the service provider require any + :vartype status: str or ~azure.mgmt.storagesync.models.PrivateEndpointServiceConnectionStatus + :ivar description: The reason for approval/rejection of the connection. + :vartype description: str + :ivar actions_required: A message indicating if changes on the service provider require any updates on the consumer. - :type actions_required: str + :vartype actions_required: str """ _attribute_map = { @@ -1207,6 +1646,16 @@ def __init__( actions_required: Optional[str] = None, **kwargs ): + """ + :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the + owner of the service. Possible values include: "Pending", "Approved", "Rejected". + :paramtype status: str or ~azure.mgmt.storagesync.models.PrivateEndpointServiceConnectionStatus + :keyword description: The reason for approval/rejection of the connection. + :paramtype description: str + :keyword actions_required: A message indicating if changes on the service provider require any + updates on the consumer. + :paramtype actions_required: str + """ super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) self.status = status self.description = description @@ -1216,10 +1665,10 @@ def __init__( class RecallActionParameters(msrest.serialization.Model): """The parameters used when calling recall action on server endpoint. - :param pattern: Pattern of the files. - :type pattern: str - :param recall_path: Recall path. - :type recall_path: str + :ivar pattern: Pattern of the files. + :vartype pattern: str + :ivar recall_path: Recall path. + :vartype recall_path: str """ _attribute_map = { @@ -1234,6 +1683,12 @@ def __init__( recall_path: Optional[str] = None, **kwargs ): + """ + :keyword pattern: Pattern of the files. + :paramtype pattern: str + :keyword recall_path: Recall path. + :paramtype recall_path: str + """ super(RecallActionParameters, self).__init__(**kwargs) self.pattern = pattern self.recall_path = recall_path @@ -1252,32 +1707,32 @@ class RegisteredServer(ProxyResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param server_certificate: Registered Server Certificate. - :type server_certificate: str - :param agent_version: Registered Server Agent Version. - :type agent_version: str + :ivar server_certificate: Registered Server Certificate. + :vartype server_certificate: str + :ivar agent_version: Registered Server Agent Version. + :vartype agent_version: str :ivar agent_version_status: Registered Server Agent Version Status. Possible values include: "Ok", "NearExpiry", "Expired", "Blocked". :vartype agent_version_status: str or ~azure.mgmt.storagesync.models.RegisteredServerAgentVersionStatus :ivar agent_version_expiration_date: Registered Server Agent Version Expiration Date. :vartype agent_version_expiration_date: ~datetime.datetime - :param server_os_version: Registered Server OS Version. - :type server_os_version: str + :ivar server_os_version: Registered Server OS Version. + :vartype server_os_version: str :ivar server_management_error_code: Registered Server Management Error Code. :vartype server_management_error_code: int :ivar last_heart_beat: Registered Server last heart beat. - :vartype last_heart_beat: ~datetime.datetime + :vartype last_heart_beat: str :ivar provisioning_state: Registered Server Provisioning State. :vartype provisioning_state: str - :param server_role: Registered Server serverRole. - :type server_role: str - :param cluster_id: Registered Server clusterId. - :type cluster_id: str - :param cluster_name: Registered Server clusterName. - :type cluster_name: str - :param server_id: Registered Server serverId. - :type server_id: str + :ivar server_role: Registered Server serverRole. + :vartype server_role: str + :ivar cluster_id: Registered Server clusterId. + :vartype cluster_id: str + :ivar cluster_name: Registered Server clusterName. + :vartype cluster_name: str + :ivar server_id: Registered Server serverId. + :vartype server_id: str :ivar storage_sync_service_uid: Registered Server storageSyncServiceUid. :vartype storage_sync_service_uid: str :ivar last_workflow_id: Registered Server lastWorkflowId. @@ -1290,8 +1745,8 @@ class RegisteredServer(ProxyResource): :vartype resource_location: str :ivar service_location: Service Location. :vartype service_location: str - :param friendly_name: Friendly Name. - :type friendly_name: str + :ivar friendly_name: Friendly Name. + :vartype friendly_name: str :ivar management_endpoint_uri: Management Endpoint Uri. :vartype management_endpoint_uri: str :ivar monitoring_endpoint_uri: Telemetry Endpoint Uri. @@ -1308,18 +1763,6 @@ class RegisteredServer(ProxyResource): 'type': {'readonly': True}, 'agent_version_status': {'readonly': True}, 'agent_version_expiration_date': {'readonly': True}, - 'server_management_error_code': {'readonly': True}, - 'last_heart_beat': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'storage_sync_service_uid': {'readonly': True}, - 'last_workflow_id': {'readonly': True}, - 'last_operation_name': {'readonly': True}, - 'discovery_endpoint_uri': {'readonly': True}, - 'resource_location': {'readonly': True}, - 'service_location': {'readonly': True}, - 'management_endpoint_uri': {'readonly': True}, - 'monitoring_endpoint_uri': {'readonly': True}, - 'monitoring_configuration': {'readonly': True}, 'server_name': {'readonly': True}, } @@ -1333,7 +1776,7 @@ class RegisteredServer(ProxyResource): 'agent_version_expiration_date': {'key': 'properties.agentVersionExpirationDate', 'type': 'iso-8601'}, 'server_os_version': {'key': 'properties.serverOSVersion', 'type': 'str'}, 'server_management_error_code': {'key': 'properties.serverManagementErrorCode', 'type': 'int'}, - 'last_heart_beat': {'key': 'properties.lastHeartBeat', 'type': 'iso-8601'}, + 'last_heart_beat': {'key': 'properties.lastHeartBeat', 'type': 'str'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, 'server_role': {'key': 'properties.serverRole', 'type': 'str'}, 'cluster_id': {'key': 'properties.clusterId', 'type': 'str'}, @@ -1358,44 +1801,98 @@ def __init__( server_certificate: Optional[str] = None, agent_version: Optional[str] = None, server_os_version: Optional[str] = None, + server_management_error_code: Optional[int] = None, + last_heart_beat: Optional[str] = None, + provisioning_state: Optional[str] = None, server_role: Optional[str] = None, cluster_id: Optional[str] = None, cluster_name: Optional[str] = None, server_id: Optional[str] = None, + storage_sync_service_uid: Optional[str] = None, + last_workflow_id: Optional[str] = None, + last_operation_name: Optional[str] = None, + discovery_endpoint_uri: Optional[str] = None, + resource_location: Optional[str] = None, + service_location: Optional[str] = None, friendly_name: Optional[str] = None, - **kwargs - ): + management_endpoint_uri: Optional[str] = None, + monitoring_endpoint_uri: Optional[str] = None, + monitoring_configuration: Optional[str] = None, + **kwargs + ): + """ + :keyword server_certificate: Registered Server Certificate. + :paramtype server_certificate: str + :keyword agent_version: Registered Server Agent Version. + :paramtype agent_version: str + :keyword server_os_version: Registered Server OS Version. + :paramtype server_os_version: str + :keyword server_management_error_code: Registered Server Management Error Code. + :paramtype server_management_error_code: int + :keyword last_heart_beat: Registered Server last heart beat. + :paramtype last_heart_beat: str + :keyword provisioning_state: Registered Server Provisioning State. + :paramtype provisioning_state: str + :keyword server_role: Registered Server serverRole. + :paramtype server_role: str + :keyword cluster_id: Registered Server clusterId. + :paramtype cluster_id: str + :keyword cluster_name: Registered Server clusterName. + :paramtype cluster_name: str + :keyword server_id: Registered Server serverId. + :paramtype server_id: str + :keyword storage_sync_service_uid: Registered Server storageSyncServiceUid. + :paramtype storage_sync_service_uid: str + :keyword last_workflow_id: Registered Server lastWorkflowId. + :paramtype last_workflow_id: str + :keyword last_operation_name: Resource Last Operation Name. + :paramtype last_operation_name: str + :keyword discovery_endpoint_uri: Resource discoveryEndpointUri. + :paramtype discovery_endpoint_uri: str + :keyword resource_location: Resource Location. + :paramtype resource_location: str + :keyword service_location: Service Location. + :paramtype service_location: str + :keyword friendly_name: Friendly Name. + :paramtype friendly_name: str + :keyword management_endpoint_uri: Management Endpoint Uri. + :paramtype management_endpoint_uri: str + :keyword monitoring_endpoint_uri: Telemetry Endpoint Uri. + :paramtype monitoring_endpoint_uri: str + :keyword monitoring_configuration: Monitoring Configuration. + :paramtype monitoring_configuration: str + """ super(RegisteredServer, self).__init__(**kwargs) self.server_certificate = server_certificate self.agent_version = agent_version self.agent_version_status = None self.agent_version_expiration_date = None self.server_os_version = server_os_version - self.server_management_error_code = None - self.last_heart_beat = None - self.provisioning_state = None + self.server_management_error_code = server_management_error_code + self.last_heart_beat = last_heart_beat + self.provisioning_state = provisioning_state self.server_role = server_role self.cluster_id = cluster_id self.cluster_name = cluster_name self.server_id = server_id - self.storage_sync_service_uid = None - self.last_workflow_id = None - self.last_operation_name = None - self.discovery_endpoint_uri = None - self.resource_location = None - self.service_location = None + self.storage_sync_service_uid = storage_sync_service_uid + self.last_workflow_id = last_workflow_id + self.last_operation_name = last_operation_name + self.discovery_endpoint_uri = discovery_endpoint_uri + self.resource_location = resource_location + self.service_location = service_location self.friendly_name = friendly_name - self.management_endpoint_uri = None - self.monitoring_endpoint_uri = None - self.monitoring_configuration = None + self.management_endpoint_uri = management_endpoint_uri + self.monitoring_endpoint_uri = monitoring_endpoint_uri + self.monitoring_configuration = monitoring_configuration self.server_name = None class RegisteredServerArray(msrest.serialization.Model): """Array of RegisteredServer. - :param value: Collection of Registered Server. - :type value: list[~azure.mgmt.storagesync.models.RegisteredServer] + :ivar value: Collection of Registered Server. + :vartype value: list[~azure.mgmt.storagesync.models.RegisteredServer] """ _attribute_map = { @@ -1408,6 +1905,10 @@ def __init__( value: Optional[List["RegisteredServer"]] = None, **kwargs ): + """ + :keyword value: Collection of Registered Server. + :paramtype value: list[~azure.mgmt.storagesync.models.RegisteredServer] + """ super(RegisteredServerArray, self).__init__(**kwargs) self.value = value @@ -1425,24 +1926,24 @@ class RegisteredServerCreateParameters(ProxyResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param server_certificate: Registered Server Certificate. - :type server_certificate: str - :param agent_version: Registered Server Agent Version. - :type agent_version: str - :param server_os_version: Registered Server OS Version. - :type server_os_version: str - :param last_heart_beat: Registered Server last heart beat. - :type last_heart_beat: str - :param server_role: Registered Server serverRole. - :type server_role: str - :param cluster_id: Registered Server clusterId. - :type cluster_id: str - :param cluster_name: Registered Server clusterName. - :type cluster_name: str - :param server_id: Registered Server serverId. - :type server_id: str - :param friendly_name: Friendly Name. - :type friendly_name: str + :ivar server_certificate: Registered Server Certificate. + :vartype server_certificate: str + :ivar agent_version: Registered Server Agent Version. + :vartype agent_version: str + :ivar server_os_version: Registered Server OS Version. + :vartype server_os_version: str + :ivar last_heart_beat: Registered Server last heart beat. + :vartype last_heart_beat: str + :ivar server_role: Registered Server serverRole. + :vartype server_role: str + :ivar cluster_id: Registered Server clusterId. + :vartype cluster_id: str + :ivar cluster_name: Registered Server clusterName. + :vartype cluster_name: str + :ivar server_id: Registered Server serverId. + :vartype server_id: str + :ivar friendly_name: Friendly Name. + :vartype friendly_name: str """ _validation = { @@ -1480,6 +1981,26 @@ def __init__( friendly_name: Optional[str] = None, **kwargs ): + """ + :keyword server_certificate: Registered Server Certificate. + :paramtype server_certificate: str + :keyword agent_version: Registered Server Agent Version. + :paramtype agent_version: str + :keyword server_os_version: Registered Server OS Version. + :paramtype server_os_version: str + :keyword last_heart_beat: Registered Server last heart beat. + :paramtype last_heart_beat: str + :keyword server_role: Registered Server serverRole. + :paramtype server_role: str + :keyword cluster_id: Registered Server clusterId. + :paramtype cluster_id: str + :keyword cluster_name: Registered Server clusterName. + :paramtype cluster_name: str + :keyword server_id: Registered Server serverId. + :paramtype server_id: str + :keyword friendly_name: Friendly Name. + :paramtype friendly_name: str + """ super(RegisteredServerCreateParameters, self).__init__(**kwargs) self.server_certificate = server_certificate self.agent_version = agent_version @@ -1495,10 +2016,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Resource Move Info. - :param target_resource_group: Target resource group. - :type target_resource_group: str - :param resources: Collection of Resources. - :type resources: list[str] + :ivar target_resource_group: Target resource group. + :vartype target_resource_group: str + :ivar resources: Collection of Resources. + :vartype resources: list[str] """ _attribute_map = { @@ -1513,6 +2034,12 @@ def __init__( resources: Optional[List[str]] = None, **kwargs ): + """ + :keyword target_resource_group: Target resource group. + :paramtype target_resource_group: str + :keyword resources: Collection of Resources. + :paramtype resources: list[str] + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.target_resource_group = target_resource_group self.resources = resources @@ -1521,10 +2048,10 @@ def __init__( class RestoreFileSpec(msrest.serialization.Model): """Restore file spec. - :param path: Restore file spec path. - :type path: str - :param isdir: Restore file spec isdir. - :type isdir: bool + :ivar path: Restore file spec path. + :vartype path: str + :ivar isdir: Restore file spec isdir. + :vartype isdir: bool """ _attribute_map = { @@ -1539,6 +2066,12 @@ def __init__( isdir: Optional[bool] = None, **kwargs ): + """ + :keyword path: Restore file spec path. + :paramtype path: str + :keyword isdir: Restore file spec isdir. + :paramtype isdir: bool + """ super(RestoreFileSpec, self).__init__(**kwargs) self.path = path self.isdir = isdir @@ -1557,19 +2090,19 @@ class ServerEndpoint(ProxyResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param server_local_path: Server Local path. - :type server_local_path: str - :param cloud_tiering: Cloud Tiering. Possible values include: "on", "off". - :type cloud_tiering: str or ~azure.mgmt.storagesync.models.FeatureStatus - :param volume_free_space_percent: Level of free space to be maintained by Cloud Tiering if it - is enabled. - :type volume_free_space_percent: int - :param tier_files_older_than_days: Tier files older than days. - :type tier_files_older_than_days: int - :param friendly_name: Friendly Name. - :type friendly_name: str - :param server_resource_id: Server Resource Id. - :type server_resource_id: str + :ivar server_local_path: Server Local path. + :vartype server_local_path: str + :ivar cloud_tiering: Cloud Tiering. Possible values include: "on", "off". + :vartype cloud_tiering: str or ~azure.mgmt.storagesync.models.FeatureStatus + :ivar volume_free_space_percent: Level of free space to be maintained by Cloud Tiering if it is + enabled. + :vartype volume_free_space_percent: int + :ivar tier_files_older_than_days: Tier files older than days. + :vartype tier_files_older_than_days: int + :ivar friendly_name: Friendly Name. + :vartype friendly_name: str + :ivar server_resource_id: Server Resource Id. + :vartype server_resource_id: str :ivar provisioning_state: ServerEndpoint Provisioning State. :vartype provisioning_state: str :ivar last_workflow_id: ServerEndpoint lastWorkflowId. @@ -1578,27 +2111,30 @@ class ServerEndpoint(ProxyResource): :vartype last_operation_name: str :ivar sync_status: Server Endpoint sync status. :vartype sync_status: ~azure.mgmt.storagesync.models.ServerEndpointSyncStatus - :param offline_data_transfer: Offline data transfer. Possible values include: "on", "off". - :type offline_data_transfer: str or ~azure.mgmt.storagesync.models.FeatureStatus + :ivar offline_data_transfer: Offline data transfer. Possible values include: "on", "off". + :vartype offline_data_transfer: str or ~azure.mgmt.storagesync.models.FeatureStatus :ivar offline_data_transfer_storage_account_resource_id: Offline data transfer storage account resource ID. :vartype offline_data_transfer_storage_account_resource_id: str :ivar offline_data_transfer_storage_account_tenant_id: Offline data transfer storage account tenant ID. :vartype offline_data_transfer_storage_account_tenant_id: str - :param offline_data_transfer_share_name: Offline data transfer share name. - :type offline_data_transfer_share_name: str + :ivar offline_data_transfer_share_name: Offline data transfer share name. + :vartype offline_data_transfer_share_name: str :ivar cloud_tiering_status: Cloud tiering status. Only populated if cloud tiering is enabled. :vartype cloud_tiering_status: ~azure.mgmt.storagesync.models.ServerEndpointCloudTieringStatus :ivar recall_status: Recall status. Only populated if cloud tiering is enabled. :vartype recall_status: ~azure.mgmt.storagesync.models.ServerEndpointRecallStatus - :param initial_download_policy: Policy for how namespace and files are recalled during FastDr. + :ivar initial_download_policy: Policy for how namespace and files are recalled during FastDr. Possible values include: "NamespaceOnly", "NamespaceThenModifiedFiles", "AvoidTieredFiles". - :type initial_download_policy: str or ~azure.mgmt.storagesync.models.InitialDownloadPolicy - :param local_cache_mode: Policy for enabling follow-the-sun business models: link local cache - to cloud behavior to pre-populate before local access. Possible values include: + :vartype initial_download_policy: str or ~azure.mgmt.storagesync.models.InitialDownloadPolicy + :ivar local_cache_mode: Policy for enabling follow-the-sun business models: link local cache to + cloud behavior to pre-populate before local access. Possible values include: "DownloadNewAndModifiedFiles", "UpdateLocallyCachedFiles". - :type local_cache_mode: str or ~azure.mgmt.storagesync.models.LocalCacheMode + :vartype local_cache_mode: str or ~azure.mgmt.storagesync.models.LocalCacheMode + :ivar initial_upload_policy: Policy for how the initial upload sync session is performed. + Possible values include: "ServerAuthoritative", "Merge". + :vartype initial_upload_policy: str or ~azure.mgmt.storagesync.models.InitialUploadPolicy :ivar server_name: Server name. :vartype server_name: str """ @@ -1642,6 +2178,7 @@ class ServerEndpoint(ProxyResource): 'recall_status': {'key': 'properties.recallStatus', 'type': 'ServerEndpointRecallStatus'}, 'initial_download_policy': {'key': 'properties.initialDownloadPolicy', 'type': 'str'}, 'local_cache_mode': {'key': 'properties.localCacheMode', 'type': 'str'}, + 'initial_upload_policy': {'key': 'properties.initialUploadPolicy', 'type': 'str'}, 'server_name': {'key': 'properties.serverName', 'type': 'str'}, } @@ -1658,8 +2195,39 @@ def __init__( offline_data_transfer_share_name: Optional[str] = None, initial_download_policy: Optional[Union[str, "InitialDownloadPolicy"]] = None, local_cache_mode: Optional[Union[str, "LocalCacheMode"]] = None, - **kwargs - ): + initial_upload_policy: Optional[Union[str, "InitialUploadPolicy"]] = None, + **kwargs + ): + """ + :keyword server_local_path: Server Local path. + :paramtype server_local_path: str + :keyword cloud_tiering: Cloud Tiering. Possible values include: "on", "off". + :paramtype cloud_tiering: str or ~azure.mgmt.storagesync.models.FeatureStatus + :keyword volume_free_space_percent: Level of free space to be maintained by Cloud Tiering if it + is enabled. + :paramtype volume_free_space_percent: int + :keyword tier_files_older_than_days: Tier files older than days. + :paramtype tier_files_older_than_days: int + :keyword friendly_name: Friendly Name. + :paramtype friendly_name: str + :keyword server_resource_id: Server Resource Id. + :paramtype server_resource_id: str + :keyword offline_data_transfer: Offline data transfer. Possible values include: "on", "off". + :paramtype offline_data_transfer: str or ~azure.mgmt.storagesync.models.FeatureStatus + :keyword offline_data_transfer_share_name: Offline data transfer share name. + :paramtype offline_data_transfer_share_name: str + :keyword initial_download_policy: Policy for how namespace and files are recalled during + FastDr. Possible values include: "NamespaceOnly", "NamespaceThenModifiedFiles", + "AvoidTieredFiles". + :paramtype initial_download_policy: str or ~azure.mgmt.storagesync.models.InitialDownloadPolicy + :keyword local_cache_mode: Policy for enabling follow-the-sun business models: link local cache + to cloud behavior to pre-populate before local access. Possible values include: + "DownloadNewAndModifiedFiles", "UpdateLocallyCachedFiles". + :paramtype local_cache_mode: str or ~azure.mgmt.storagesync.models.LocalCacheMode + :keyword initial_upload_policy: Policy for how the initial upload sync session is performed. + Possible values include: "ServerAuthoritative", "Merge". + :paramtype initial_upload_policy: str or ~azure.mgmt.storagesync.models.InitialUploadPolicy + """ super(ServerEndpoint, self).__init__(**kwargs) self.server_local_path = server_local_path self.cloud_tiering = cloud_tiering @@ -1679,14 +2247,15 @@ def __init__( self.recall_status = None self.initial_download_policy = initial_download_policy self.local_cache_mode = local_cache_mode + self.initial_upload_policy = initial_upload_policy self.server_name = None class ServerEndpointArray(msrest.serialization.Model): """Array of ServerEndpoint. - :param value: Collection of ServerEndpoint. - :type value: list[~azure.mgmt.storagesync.models.ServerEndpoint] + :ivar value: Collection of ServerEndpoint. + :vartype value: list[~azure.mgmt.storagesync.models.ServerEndpoint] """ _attribute_map = { @@ -1699,6 +2268,10 @@ def __init__( value: Optional[List["ServerEndpoint"]] = None, **kwargs ): + """ + :keyword value: Collection of ServerEndpoint. + :paramtype value: list[~azure.mgmt.storagesync.models.ServerEndpoint] + """ super(ServerEndpointArray, self).__init__(**kwargs) self.value = value @@ -1710,6 +2283,8 @@ class ServerEndpointBackgroundDataDownloadActivity(msrest.serialization.Model): :ivar timestamp: Timestamp when properties were updated. :vartype timestamp: ~datetime.datetime + :ivar started_timestamp: Timestamp when the operation started. + :vartype started_timestamp: ~datetime.datetime :ivar percent_progress: Progress percentage. :vartype percent_progress: int :ivar downloaded_bytes: Running count of bytes downloaded. @@ -1718,12 +2293,14 @@ class ServerEndpointBackgroundDataDownloadActivity(msrest.serialization.Model): _validation = { 'timestamp': {'readonly': True}, + 'started_timestamp': {'readonly': True}, 'percent_progress': {'readonly': True, 'maximum': 100, 'minimum': 0}, 'downloaded_bytes': {'readonly': True, 'minimum': 0}, } _attribute_map = { 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + 'started_timestamp': {'key': 'startedTimestamp', 'type': 'iso-8601'}, 'percent_progress': {'key': 'percentProgress', 'type': 'int'}, 'downloaded_bytes': {'key': 'downloadedBytes', 'type': 'long'}, } @@ -1732,8 +2309,11 @@ def __init__( self, **kwargs ): + """ + """ super(ServerEndpointBackgroundDataDownloadActivity, self).__init__(**kwargs) self.timestamp = None + self.started_timestamp = None self.percent_progress = None self.downloaded_bytes = None @@ -1798,6 +2378,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServerEndpointCloudTieringStatus, self).__init__(**kwargs) self.last_updated_timestamp = None self.health = None @@ -1824,30 +2406,33 @@ class ServerEndpointCreateParameters(ProxyResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param server_local_path: Server Local path. - :type server_local_path: str - :param cloud_tiering: Cloud Tiering. Possible values include: "on", "off". - :type cloud_tiering: str or ~azure.mgmt.storagesync.models.FeatureStatus - :param volume_free_space_percent: Level of free space to be maintained by Cloud Tiering if it - is enabled. - :type volume_free_space_percent: int - :param tier_files_older_than_days: Tier files older than days. - :type tier_files_older_than_days: int - :param friendly_name: Friendly Name. - :type friendly_name: str - :param server_resource_id: Server Resource Id. - :type server_resource_id: str - :param offline_data_transfer: Offline data transfer. Possible values include: "on", "off". - :type offline_data_transfer: str or ~azure.mgmt.storagesync.models.FeatureStatus - :param offline_data_transfer_share_name: Offline data transfer share name. - :type offline_data_transfer_share_name: str - :param initial_download_policy: Policy for how namespace and files are recalled during FastDr. + :ivar server_local_path: Server Local path. + :vartype server_local_path: str + :ivar cloud_tiering: Cloud Tiering. Possible values include: "on", "off". + :vartype cloud_tiering: str or ~azure.mgmt.storagesync.models.FeatureStatus + :ivar volume_free_space_percent: Level of free space to be maintained by Cloud Tiering if it is + enabled. + :vartype volume_free_space_percent: int + :ivar tier_files_older_than_days: Tier files older than days. + :vartype tier_files_older_than_days: int + :ivar friendly_name: Friendly Name. + :vartype friendly_name: str + :ivar server_resource_id: Server Resource Id. + :vartype server_resource_id: str + :ivar offline_data_transfer: Offline data transfer. Possible values include: "on", "off". + :vartype offline_data_transfer: str or ~azure.mgmt.storagesync.models.FeatureStatus + :ivar offline_data_transfer_share_name: Offline data transfer share name. + :vartype offline_data_transfer_share_name: str + :ivar initial_download_policy: Policy for how namespace and files are recalled during FastDr. Possible values include: "NamespaceOnly", "NamespaceThenModifiedFiles", "AvoidTieredFiles". - :type initial_download_policy: str or ~azure.mgmt.storagesync.models.InitialDownloadPolicy - :param local_cache_mode: Policy for enabling follow-the-sun business models: link local cache - to cloud behavior to pre-populate before local access. Possible values include: + :vartype initial_download_policy: str or ~azure.mgmt.storagesync.models.InitialDownloadPolicy + :ivar local_cache_mode: Policy for enabling follow-the-sun business models: link local cache to + cloud behavior to pre-populate before local access. Possible values include: "DownloadNewAndModifiedFiles", "UpdateLocallyCachedFiles". - :type local_cache_mode: str or ~azure.mgmt.storagesync.models.LocalCacheMode + :vartype local_cache_mode: str or ~azure.mgmt.storagesync.models.LocalCacheMode + :ivar initial_upload_policy: Policy for how the initial upload sync session is performed. + Possible values include: "ServerAuthoritative", "Merge". + :vartype initial_upload_policy: str or ~azure.mgmt.storagesync.models.InitialUploadPolicy """ _validation = { @@ -1872,6 +2457,7 @@ class ServerEndpointCreateParameters(ProxyResource): 'offline_data_transfer_share_name': {'key': 'properties.offlineDataTransferShareName', 'type': 'str'}, 'initial_download_policy': {'key': 'properties.initialDownloadPolicy', 'type': 'str'}, 'local_cache_mode': {'key': 'properties.localCacheMode', 'type': 'str'}, + 'initial_upload_policy': {'key': 'properties.initialUploadPolicy', 'type': 'str'}, } def __init__( @@ -1879,7 +2465,7 @@ def __init__( *, server_local_path: Optional[str] = None, cloud_tiering: Optional[Union[str, "FeatureStatus"]] = None, - volume_free_space_percent: Optional[int] = None, + volume_free_space_percent: Optional[int] = 20, tier_files_older_than_days: Optional[int] = None, friendly_name: Optional[str] = None, server_resource_id: Optional[str] = None, @@ -1887,8 +2473,39 @@ def __init__( offline_data_transfer_share_name: Optional[str] = None, initial_download_policy: Optional[Union[str, "InitialDownloadPolicy"]] = None, local_cache_mode: Optional[Union[str, "LocalCacheMode"]] = None, - **kwargs - ): + initial_upload_policy: Optional[Union[str, "InitialUploadPolicy"]] = None, + **kwargs + ): + """ + :keyword server_local_path: Server Local path. + :paramtype server_local_path: str + :keyword cloud_tiering: Cloud Tiering. Possible values include: "on", "off". + :paramtype cloud_tiering: str or ~azure.mgmt.storagesync.models.FeatureStatus + :keyword volume_free_space_percent: Level of free space to be maintained by Cloud Tiering if it + is enabled. + :paramtype volume_free_space_percent: int + :keyword tier_files_older_than_days: Tier files older than days. + :paramtype tier_files_older_than_days: int + :keyword friendly_name: Friendly Name. + :paramtype friendly_name: str + :keyword server_resource_id: Server Resource Id. + :paramtype server_resource_id: str + :keyword offline_data_transfer: Offline data transfer. Possible values include: "on", "off". + :paramtype offline_data_transfer: str or ~azure.mgmt.storagesync.models.FeatureStatus + :keyword offline_data_transfer_share_name: Offline data transfer share name. + :paramtype offline_data_transfer_share_name: str + :keyword initial_download_policy: Policy for how namespace and files are recalled during + FastDr. Possible values include: "NamespaceOnly", "NamespaceThenModifiedFiles", + "AvoidTieredFiles". + :paramtype initial_download_policy: str or ~azure.mgmt.storagesync.models.InitialDownloadPolicy + :keyword local_cache_mode: Policy for enabling follow-the-sun business models: link local cache + to cloud behavior to pre-populate before local access. Possible values include: + "DownloadNewAndModifiedFiles", "UpdateLocallyCachedFiles". + :paramtype local_cache_mode: str or ~azure.mgmt.storagesync.models.LocalCacheMode + :keyword initial_upload_policy: Policy for how the initial upload sync session is performed. + Possible values include: "ServerAuthoritative", "Merge". + :paramtype initial_upload_policy: str or ~azure.mgmt.storagesync.models.InitialUploadPolicy + """ super(ServerEndpointCreateParameters, self).__init__(**kwargs) self.server_local_path = server_local_path self.cloud_tiering = cloud_tiering @@ -1900,6 +2517,7 @@ def __init__( self.offline_data_transfer_share_name = offline_data_transfer_share_name self.initial_download_policy = initial_download_policy self.local_cache_mode = local_cache_mode + self.initial_upload_policy = initial_upload_policy class ServerEndpointFilesNotSyncingError(msrest.serialization.Model): @@ -1931,6 +2549,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServerEndpointFilesNotSyncingError, self).__init__(**kwargs) self.error_code = None self.persistent_count = None @@ -1962,6 +2582,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServerEndpointRecallError, self).__init__(**kwargs) self.error_code = None self.count = None @@ -1996,6 +2618,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServerEndpointRecallStatus, self).__init__(**kwargs) self.last_updated_timestamp = None self.total_recall_errors_count = None @@ -2022,6 +2646,8 @@ class ServerEndpointSyncActivityStatus(msrest.serialization.Model): :ivar sync_mode: Sync mode. Possible values include: "Regular", "NamespaceDownload", "InitialUpload", "SnapshotUpload", "InitialFullDownload". :vartype sync_mode: str or ~azure.mgmt.storagesync.models.ServerEndpointSyncMode + :ivar session_minutes_remaining: Session minutes remaining (if available). + :vartype session_minutes_remaining: int """ _validation = { @@ -2032,6 +2658,7 @@ class ServerEndpointSyncActivityStatus(msrest.serialization.Model): 'applied_bytes': {'readonly': True, 'minimum': 0}, 'total_bytes': {'readonly': True, 'minimum': 0}, 'sync_mode': {'readonly': True}, + 'session_minutes_remaining': {'readonly': True, 'minimum': 0}, } _attribute_map = { @@ -2042,12 +2669,15 @@ class ServerEndpointSyncActivityStatus(msrest.serialization.Model): 'applied_bytes': {'key': 'appliedBytes', 'type': 'long'}, 'total_bytes': {'key': 'totalBytes', 'type': 'long'}, 'sync_mode': {'key': 'syncMode', 'type': 'str'}, + 'session_minutes_remaining': {'key': 'sessionMinutesRemaining', 'type': 'int'}, } def __init__( self, **kwargs ): + """ + """ super(ServerEndpointSyncActivityStatus, self).__init__(**kwargs) self.timestamp = None self.per_item_error_count = None @@ -2056,6 +2686,7 @@ def __init__( self.applied_bytes = None self.total_bytes = None self.sync_mode = None + self.session_minutes_remaining = None class ServerEndpointSyncSessionStatus(msrest.serialization.Model): @@ -2109,6 +2740,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServerEndpointSyncSessionStatus, self).__init__(**kwargs) self.last_sync_result = None self.last_sync_timestamp = None @@ -2193,6 +2826,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServerEndpointSyncStatus, self).__init__(**kwargs) self.download_health = None self.upload_health = None @@ -2211,21 +2846,21 @@ def __init__( class ServerEndpointUpdateParameters(msrest.serialization.Model): """Parameters for updating an Server Endpoint. - :param cloud_tiering: Cloud Tiering. Possible values include: "on", "off". - :type cloud_tiering: str or ~azure.mgmt.storagesync.models.FeatureStatus - :param volume_free_space_percent: Level of free space to be maintained by Cloud Tiering if it - is enabled. - :type volume_free_space_percent: int - :param tier_files_older_than_days: Tier files older than days. - :type tier_files_older_than_days: int - :param offline_data_transfer: Offline data transfer. Possible values include: "on", "off". - :type offline_data_transfer: str or ~azure.mgmt.storagesync.models.FeatureStatus - :param offline_data_transfer_share_name: Offline data transfer share name. - :type offline_data_transfer_share_name: str - :param local_cache_mode: Policy for enabling follow-the-sun business models: link local cache - to cloud behavior to pre-populate before local access. Possible values include: + :ivar cloud_tiering: Cloud Tiering. Possible values include: "on", "off". + :vartype cloud_tiering: str or ~azure.mgmt.storagesync.models.FeatureStatus + :ivar volume_free_space_percent: Level of free space to be maintained by Cloud Tiering if it is + enabled. + :vartype volume_free_space_percent: int + :ivar tier_files_older_than_days: Tier files older than days. + :vartype tier_files_older_than_days: int + :ivar offline_data_transfer: Offline data transfer. Possible values include: "on", "off". + :vartype offline_data_transfer: str or ~azure.mgmt.storagesync.models.FeatureStatus + :ivar offline_data_transfer_share_name: Offline data transfer share name. + :vartype offline_data_transfer_share_name: str + :ivar local_cache_mode: Policy for enabling follow-the-sun business models: link local cache to + cloud behavior to pre-populate before local access. Possible values include: "DownloadNewAndModifiedFiles", "UpdateLocallyCachedFiles". - :type local_cache_mode: str or ~azure.mgmt.storagesync.models.LocalCacheMode + :vartype local_cache_mode: str or ~azure.mgmt.storagesync.models.LocalCacheMode """ _validation = { @@ -2253,6 +2888,23 @@ def __init__( local_cache_mode: Optional[Union[str, "LocalCacheMode"]] = None, **kwargs ): + """ + :keyword cloud_tiering: Cloud Tiering. Possible values include: "on", "off". + :paramtype cloud_tiering: str or ~azure.mgmt.storagesync.models.FeatureStatus + :keyword volume_free_space_percent: Level of free space to be maintained by Cloud Tiering if it + is enabled. + :paramtype volume_free_space_percent: int + :keyword tier_files_older_than_days: Tier files older than days. + :paramtype tier_files_older_than_days: int + :keyword offline_data_transfer: Offline data transfer. Possible values include: "on", "off". + :paramtype offline_data_transfer: str or ~azure.mgmt.storagesync.models.FeatureStatus + :keyword offline_data_transfer_share_name: Offline data transfer share name. + :paramtype offline_data_transfer_share_name: str + :keyword local_cache_mode: Policy for enabling follow-the-sun business models: link local cache + to cloud behavior to pre-populate before local access. Possible values include: + "DownloadNewAndModifiedFiles", "UpdateLocallyCachedFiles". + :paramtype local_cache_mode: str or ~azure.mgmt.storagesync.models.LocalCacheMode + """ super(ServerEndpointUpdateParameters, self).__init__(**kwargs) self.cloud_tiering = cloud_tiering self.volume_free_space_percent = volume_free_space_percent @@ -2265,16 +2917,16 @@ def __init__( class StorageSyncApiError(msrest.serialization.Model): """Error type. - :param code: Error code of the given entry. - :type code: str - :param message: Error message of the given entry. - :type message: str - :param target: Target of the given error entry. - :type target: str - :param details: Error details of the given entry. - :type details: ~azure.mgmt.storagesync.models.StorageSyncErrorDetails - :param inner_error: Inner error details of the given entry. - :type inner_error: ~azure.mgmt.storagesync.models.StorageSyncInnerErrorDetails + :ivar code: Error code of the given entry. + :vartype code: str + :ivar message: Error message of the given entry. + :vartype message: str + :ivar target: Target of the given error entry. + :vartype target: str + :ivar details: Error details of the given entry. + :vartype details: ~azure.mgmt.storagesync.models.StorageSyncErrorDetails + :ivar inner_error: Inner error details of the given entry. + :vartype inner_error: ~azure.mgmt.storagesync.models.StorageSyncInnerErrorDetails """ _attribute_map = { @@ -2295,6 +2947,18 @@ def __init__( inner_error: Optional["StorageSyncInnerErrorDetails"] = None, **kwargs ): + """ + :keyword code: Error code of the given entry. + :paramtype code: str + :keyword message: Error message of the given entry. + :paramtype message: str + :keyword target: Target of the given error entry. + :paramtype target: str + :keyword details: Error details of the given entry. + :paramtype details: ~azure.mgmt.storagesync.models.StorageSyncErrorDetails + :keyword inner_error: Inner error details of the given entry. + :paramtype inner_error: ~azure.mgmt.storagesync.models.StorageSyncInnerErrorDetails + """ super(StorageSyncApiError, self).__init__(**kwargs) self.code = code self.message = message @@ -2306,10 +2970,10 @@ def __init__( class StorageSyncError(msrest.serialization.Model): """Error type. - :param error: Error details of the given entry. - :type error: ~azure.mgmt.storagesync.models.StorageSyncApiError - :param innererror: Error details of the given entry. - :type innererror: ~azure.mgmt.storagesync.models.StorageSyncApiError + :ivar error: Error details of the given entry. + :vartype error: ~azure.mgmt.storagesync.models.StorageSyncApiError + :ivar innererror: Error details of the given entry. + :vartype innererror: ~azure.mgmt.storagesync.models.StorageSyncApiError """ _attribute_map = { @@ -2324,6 +2988,12 @@ def __init__( innererror: Optional["StorageSyncApiError"] = None, **kwargs ): + """ + :keyword error: Error details of the given entry. + :paramtype error: ~azure.mgmt.storagesync.models.StorageSyncApiError + :keyword innererror: Error details of the given entry. + :paramtype innererror: ~azure.mgmt.storagesync.models.StorageSyncApiError + """ super(StorageSyncError, self).__init__(**kwargs) self.error = error self.innererror = innererror @@ -2332,22 +3002,22 @@ def __init__( class StorageSyncErrorDetails(msrest.serialization.Model): """Error Details object. - :param code: Error code of the given entry. - :type code: str - :param message: Error message of the given entry. - :type message: str - :param target: Target of the given entry. - :type target: str - :param request_uri: Request URI of the given entry. - :type request_uri: str - :param exception_type: Exception type of the given entry. - :type exception_type: str - :param http_method: HTTP method of the given entry. - :type http_method: str - :param hashed_message: Hashed message of the given entry. - :type hashed_message: str - :param http_error_code: HTTP error code of the given entry. - :type http_error_code: str + :ivar code: Error code of the given entry. + :vartype code: str + :ivar message: Error message of the given entry. + :vartype message: str + :ivar target: Target of the given entry. + :vartype target: str + :ivar request_uri: Request URI of the given entry. + :vartype request_uri: str + :ivar exception_type: Exception type of the given entry. + :vartype exception_type: str + :ivar http_method: HTTP method of the given entry. + :vartype http_method: str + :ivar hashed_message: Hashed message of the given entry. + :vartype hashed_message: str + :ivar http_error_code: HTTP error code of the given entry. + :vartype http_error_code: str """ _attribute_map = { @@ -2374,6 +3044,24 @@ def __init__( http_error_code: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code of the given entry. + :paramtype code: str + :keyword message: Error message of the given entry. + :paramtype message: str + :keyword target: Target of the given entry. + :paramtype target: str + :keyword request_uri: Request URI of the given entry. + :paramtype request_uri: str + :keyword exception_type: Exception type of the given entry. + :paramtype exception_type: str + :keyword http_method: HTTP method of the given entry. + :paramtype http_method: str + :keyword hashed_message: Hashed message of the given entry. + :paramtype hashed_message: str + :keyword http_error_code: HTTP error code of the given entry. + :paramtype http_error_code: str + """ super(StorageSyncErrorDetails, self).__init__(**kwargs) self.code = code self.message = message @@ -2388,14 +3076,14 @@ def __init__( class StorageSyncInnerErrorDetails(msrest.serialization.Model): """Error Details object. - :param call_stack: Call stack of the error. - :type call_stack: str - :param message: Error message of the error. - :type message: str - :param inner_exception: Exception of the inner error. - :type inner_exception: str - :param inner_exception_call_stack: Call stack of the inner error. - :type inner_exception_call_stack: str + :ivar call_stack: Call stack of the error. + :vartype call_stack: str + :ivar message: Error message of the error. + :vartype message: str + :ivar inner_exception: Exception of the inner error. + :vartype inner_exception: str + :ivar inner_exception_call_stack: Call stack of the inner error. + :vartype inner_exception_call_stack: str """ _attribute_map = { @@ -2414,6 +3102,16 @@ def __init__( inner_exception_call_stack: Optional[str] = None, **kwargs ): + """ + :keyword call_stack: Call stack of the error. + :paramtype call_stack: str + :keyword message: Error message of the error. + :paramtype message: str + :keyword inner_exception: Exception of the inner error. + :paramtype inner_exception: str + :keyword inner_exception_call_stack: Call stack of the inner error. + :paramtype inner_exception_call_stack: str + """ super(StorageSyncInnerErrorDetails, self).__init__(**kwargs) self.call_stack = call_stack self.message = message @@ -2436,10 +3134,10 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str """ _validation = { @@ -2464,6 +3162,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + """ super(TrackedResource, self).__init__(**kwargs) self.tags = tags self.location = location @@ -2484,13 +3188,13 @@ class StorageSyncService(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param incoming_traffic_policy: Incoming Traffic Policy. Possible values include: + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar incoming_traffic_policy: Incoming Traffic Policy. Possible values include: "AllowAllTraffic", "AllowVirtualNetworksOnly". - :type incoming_traffic_policy: str or ~azure.mgmt.storagesync.models.IncomingTrafficPolicy + :vartype incoming_traffic_policy: str or ~azure.mgmt.storagesync.models.IncomingTrafficPolicy :ivar storage_sync_service_status: Storage Sync service status. :vartype storage_sync_service_status: int :ivar storage_sync_service_uid: Storage Sync service Uid. @@ -2543,6 +3247,15 @@ def __init__( incoming_traffic_policy: Optional[Union[str, "IncomingTrafficPolicy"]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword incoming_traffic_policy: Incoming Traffic Policy. Possible values include: + "AllowAllTraffic", "AllowVirtualNetworksOnly". + :paramtype incoming_traffic_policy: str or ~azure.mgmt.storagesync.models.IncomingTrafficPolicy + """ super(StorageSyncService, self).__init__(tags=tags, location=location, **kwargs) self.incoming_traffic_policy = incoming_traffic_policy self.storage_sync_service_status = None @@ -2556,8 +3269,8 @@ def __init__( class StorageSyncServiceArray(msrest.serialization.Model): """Array of StorageSyncServices. - :param value: Collection of StorageSyncServices. - :type value: list[~azure.mgmt.storagesync.models.StorageSyncService] + :ivar value: Collection of StorageSyncServices. + :vartype value: list[~azure.mgmt.storagesync.models.StorageSyncService] """ _attribute_map = { @@ -2570,6 +3283,10 @@ def __init__( value: Optional[List["StorageSyncService"]] = None, **kwargs ): + """ + :keyword value: Collection of StorageSyncServices. + :paramtype value: list[~azure.mgmt.storagesync.models.StorageSyncService] + """ super(StorageSyncServiceArray, self).__init__(**kwargs) self.value = value @@ -2579,19 +3296,19 @@ class StorageSyncServiceCreateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. Required. Gets or sets the location of the resource. This will be - one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, + :ivar location: Required. Required. Gets or sets the location of the resource. This will be one + of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The geo region of a resource cannot be changed once it is created, but if an identical geo region is specified on update, the request will succeed. - :type location: str - :param tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. + :vartype location: str + :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. These tags can be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key with a length no greater than 128 characters and a value with a length no greater than 256 characters. - :type tags: dict[str, str] - :param incoming_traffic_policy: Incoming Traffic Policy. Possible values include: + :vartype tags: dict[str, str] + :ivar incoming_traffic_policy: Incoming Traffic Policy. Possible values include: "AllowAllTraffic", "AllowVirtualNetworksOnly". - :type incoming_traffic_policy: str or ~azure.mgmt.storagesync.models.IncomingTrafficPolicy + :vartype incoming_traffic_policy: str or ~azure.mgmt.storagesync.models.IncomingTrafficPolicy """ _validation = { @@ -2612,6 +3329,21 @@ def __init__( incoming_traffic_policy: Optional[Union[str, "IncomingTrafficPolicy"]] = None, **kwargs ): + """ + :keyword location: Required. Required. Gets or sets the location of the resource. This will be + one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, + etc.). The geo region of a resource cannot be changed once it is created, but if an identical + geo region is specified on update, the request will succeed. + :paramtype location: str + :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the + resource. These tags can be used for viewing and grouping this resource (across resource + groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key with a + length no greater than 128 characters and a value with a length no greater than 256 characters. + :paramtype tags: dict[str, str] + :keyword incoming_traffic_policy: Incoming Traffic Policy. Possible values include: + "AllowAllTraffic", "AllowVirtualNetworksOnly". + :paramtype incoming_traffic_policy: str or ~azure.mgmt.storagesync.models.IncomingTrafficPolicy + """ super(StorageSyncServiceCreateParameters, self).__init__(**kwargs) self.location = location self.tags = tags @@ -2621,11 +3353,11 @@ def __init__( class StorageSyncServiceUpdateParameters(msrest.serialization.Model): """Parameters for updating an Storage sync service. - :param tags: A set of tags. The user-specified tags associated with the storage sync service. - :type tags: dict[str, str] - :param incoming_traffic_policy: Incoming Traffic Policy. Possible values include: + :ivar tags: A set of tags. The user-specified tags associated with the storage sync service. + :vartype tags: dict[str, str] + :ivar incoming_traffic_policy: Incoming Traffic Policy. Possible values include: "AllowAllTraffic", "AllowVirtualNetworksOnly". - :type incoming_traffic_policy: str or ~azure.mgmt.storagesync.models.IncomingTrafficPolicy + :vartype incoming_traffic_policy: str or ~azure.mgmt.storagesync.models.IncomingTrafficPolicy """ _attribute_map = { @@ -2640,6 +3372,13 @@ def __init__( incoming_traffic_policy: Optional[Union[str, "IncomingTrafficPolicy"]] = None, **kwargs ): + """ + :keyword tags: A set of tags. The user-specified tags associated with the storage sync service. + :paramtype tags: dict[str, str] + :keyword incoming_traffic_policy: Incoming Traffic Policy. Possible values include: + "AllowAllTraffic", "AllowVirtualNetworksOnly". + :paramtype incoming_traffic_policy: str or ~azure.mgmt.storagesync.models.IncomingTrafficPolicy + """ super(StorageSyncServiceUpdateParameters, self).__init__(**kwargs) self.tags = tags self.incoming_traffic_policy = incoming_traffic_policy @@ -2650,13 +3389,13 @@ class SubscriptionState(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param state: State of Azure Subscription. Possible values include: "Registered", + :ivar state: State of Azure Subscription. Possible values include: "Registered", "Unregistered", "Warned", "Suspended", "Deleted". - :type state: str or ~azure.mgmt.storagesync.models.Reason + :vartype state: str or ~azure.mgmt.storagesync.models.Reason :ivar istransitioning: Is Transitioning. :vartype istransitioning: bool - :param properties: Subscription state properties. - :type properties: object + :ivar properties: Subscription state properties. + :vartype properties: any """ _validation = { @@ -2673,9 +3412,16 @@ def __init__( self, *, state: Optional[Union[str, "Reason"]] = None, - properties: Optional[object] = None, + properties: Optional[Any] = None, **kwargs ): + """ + :keyword state: State of Azure Subscription. Possible values include: "Registered", + "Unregistered", "Warned", "Suspended", "Deleted". + :paramtype state: str or ~azure.mgmt.storagesync.models.Reason + :keyword properties: Subscription state properties. + :paramtype properties: any + """ super(SubscriptionState, self).__init__(**kwargs) self.state = state self.istransitioning = None @@ -2721,6 +3467,8 @@ def __init__( self, **kwargs ): + """ + """ super(SyncGroup, self).__init__(**kwargs) self.unique_id = None self.sync_group_status = None @@ -2729,8 +3477,8 @@ def __init__( class SyncGroupArray(msrest.serialization.Model): """Array of SyncGroup. - :param value: Collection of SyncGroup. - :type value: list[~azure.mgmt.storagesync.models.SyncGroup] + :ivar value: Collection of SyncGroup. + :vartype value: list[~azure.mgmt.storagesync.models.SyncGroup] """ _attribute_map = { @@ -2743,6 +3491,10 @@ def __init__( value: Optional[List["SyncGroup"]] = None, **kwargs ): + """ + :keyword value: Collection of SyncGroup. + :paramtype value: list[~azure.mgmt.storagesync.models.SyncGroup] + """ super(SyncGroupArray, self).__init__(**kwargs) self.value = value @@ -2760,8 +3512,8 @@ class SyncGroupCreateParameters(ProxyResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param properties: The parameters used to create the sync group. - :type properties: object + :ivar properties: The parameters used to create the sync group. + :vartype properties: any """ _validation = { @@ -2780,9 +3532,13 @@ class SyncGroupCreateParameters(ProxyResource): def __init__( self, *, - properties: Optional[object] = None, + properties: Optional[Any] = None, **kwargs ): + """ + :keyword properties: The parameters used to create the sync group. + :paramtype properties: any + """ super(SyncGroupCreateParameters, self).__init__(**kwargs) self.properties = properties @@ -2790,15 +3546,15 @@ def __init__( class TriggerChangeDetectionParameters(msrest.serialization.Model): """The parameters used when calling trigger change detection action on cloud endpoint. - :param directory_path: Relative path to a directory Azure File share for which change detection + :ivar directory_path: Relative path to a directory Azure File share for which change detection is to be performed. - :type directory_path: str - :param change_detection_mode: Change Detection Mode. Applies to a directory specified in + :vartype directory_path: str + :ivar change_detection_mode: Change Detection Mode. Applies to a directory specified in directoryPath parameter. Possible values include: "Default", "Recursive". - :type change_detection_mode: str or ~azure.mgmt.storagesync.models.ChangeDetectionMode - :param paths: Array of relative paths on the Azure File share to be included in the change + :vartype change_detection_mode: str or ~azure.mgmt.storagesync.models.ChangeDetectionMode + :ivar paths: Array of relative paths on the Azure File share to be included in the change detection. Can be files and directories. - :type paths: list[str] + :vartype paths: list[str] """ _attribute_map = { @@ -2815,6 +3571,17 @@ def __init__( paths: Optional[List[str]] = None, **kwargs ): + """ + :keyword directory_path: Relative path to a directory Azure File share for which change + detection is to be performed. + :paramtype directory_path: str + :keyword change_detection_mode: Change Detection Mode. Applies to a directory specified in + directoryPath parameter. Possible values include: "Default", "Recursive". + :paramtype change_detection_mode: str or ~azure.mgmt.storagesync.models.ChangeDetectionMode + :keyword paths: Array of relative paths on the Azure File share to be included in the change + detection. Can be files and directories. + :paramtype paths: list[str] + """ super(TriggerChangeDetectionParameters, self).__init__(**kwargs) self.directory_path = directory_path self.change_detection_mode = change_detection_mode @@ -2824,8 +3591,8 @@ def __init__( class TriggerRolloverRequest(msrest.serialization.Model): """Trigger Rollover Request. - :param server_certificate: Certificate Data. - :type server_certificate: str + :ivar server_certificate: Certificate Data. + :vartype server_certificate: str """ _attribute_map = { @@ -2838,6 +3605,10 @@ def __init__( server_certificate: Optional[str] = None, **kwargs ): + """ + :keyword server_certificate: Certificate Data. + :paramtype server_certificate: str + """ super(TriggerRolloverRequest, self).__init__(**kwargs) self.server_certificate = server_certificate @@ -2878,11 +3649,6 @@ class Workflow(ProxyResource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'last_step_name': {'readonly': True}, - 'status': {'readonly': True}, - 'operation': {'readonly': True}, - 'steps': {'readonly': True}, - 'last_operation_id': {'readonly': True}, 'command_name': {'readonly': True}, 'created_timestamp': {'readonly': True}, 'last_status_timestamp': {'readonly': True}, @@ -2904,14 +3670,33 @@ class Workflow(ProxyResource): def __init__( self, - **kwargs - ): + *, + last_step_name: Optional[str] = None, + status: Optional[Union[str, "WorkflowStatus"]] = None, + operation: Optional[Union[str, "OperationDirection"]] = None, + steps: Optional[str] = None, + last_operation_id: Optional[str] = None, + **kwargs + ): + """ + :keyword last_step_name: last step name. + :paramtype last_step_name: str + :keyword status: workflow status. Possible values include: "active", "expired", "succeeded", + "aborted", "failed". + :paramtype status: str or ~azure.mgmt.storagesync.models.WorkflowStatus + :keyword operation: operation direction. Possible values include: "do", "undo", "cancel". + :paramtype operation: str or ~azure.mgmt.storagesync.models.OperationDirection + :keyword steps: workflow steps. + :paramtype steps: str + :keyword last_operation_id: workflow last operation identifier. + :paramtype last_operation_id: str + """ super(Workflow, self).__init__(**kwargs) - self.last_step_name = None - self.status = None - self.operation = None - self.steps = None - self.last_operation_id = None + self.last_step_name = last_step_name + self.status = status + self.operation = operation + self.steps = steps + self.last_operation_id = last_operation_id self.command_name = None self.created_timestamp = None self.last_status_timestamp = None @@ -2920,8 +3705,8 @@ def __init__( class WorkflowArray(msrest.serialization.Model): """Array of Workflow. - :param value: Collection of workflow items. - :type value: list[~azure.mgmt.storagesync.models.Workflow] + :ivar value: Collection of workflow items. + :vartype value: list[~azure.mgmt.storagesync.models.Workflow] """ _attribute_map = { @@ -2934,5 +3719,9 @@ def __init__( value: Optional[List["Workflow"]] = None, **kwargs ): + """ + :keyword value: Collection of workflow items. + :paramtype value: list[~azure.mgmt.storagesync.models.Workflow] + """ super(WorkflowArray, self).__init__(**kwargs) self.value = value diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/__init__.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/__init__.py index 85ce9379c268..6498106a813e 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/__init__.py @@ -16,6 +16,7 @@ from ._registered_servers_operations import RegisteredServersOperations from ._workflows_operations import WorkflowsOperations from ._operation_status_operations import OperationStatusOperations +from ._microsoft_storage_sync_operations import MicrosoftStorageSyncOperationsMixin __all__ = [ 'Operations', @@ -28,4 +29,5 @@ 'RegisteredServersOperations', 'WorkflowsOperations', 'OperationStatusOperations', + 'MicrosoftStorageSyncOperationsMixin', ] diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_cloud_endpoints_operations.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_cloud_endpoints_operations.py index 73ad716cfc57..2dcf601e90b9 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_cloud_endpoints_operations.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_cloud_endpoints_operations.py @@ -5,25 +5,470 @@ # 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_create_request_initial( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "cloudEndpointName": _SERIALIZER.url("cloud_endpoint_name", cloud_endpoint_name, '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] + 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_get_request( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "cloudEndpointName": _SERIALIZER.url("cloud_endpoint_name", cloud_endpoint_name, '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( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "cloudEndpointName": _SERIALIZER.url("cloud_endpoint_name", cloud_endpoint_name, '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_list_by_sync_group_request( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, '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_pre_backup_request_initial( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/prebackup') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "cloudEndpointName": _SERIALIZER.url("cloud_endpoint_name", cloud_endpoint_name, '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] + 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_post_backup_request_initial( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/postbackup') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "cloudEndpointName": _SERIALIZER.url("cloud_endpoint_name", cloud_endpoint_name, '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] + 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_pre_restore_request_initial( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/prerestore') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "cloudEndpointName": _SERIALIZER.url("cloud_endpoint_name", cloud_endpoint_name, '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] + 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_restoreheartbeat_request( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/restoreheartbeat') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "cloudEndpointName": _SERIALIZER.url("cloud_endpoint_name", cloud_endpoint_name, '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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_post_restore_request_initial( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/postrestore') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "cloudEndpointName": _SERIALIZER.url("cloud_endpoint_name", cloud_endpoint_name, '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] + 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_trigger_change_detection_request_initial( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/triggerChangeDetection') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "cloudEndpointName": _SERIALIZER.url("cloud_endpoint_name", cloud_endpoint_name, '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] + 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class CloudEndpointsOperations(object): """CloudEndpointsOperations operations. @@ -49,60 +494,49 @@ def __init__(self, client, config, serializer, deserializer): def _create_initial( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - cloud_endpoint_name, # type: str - parameters, # type: "_models.CloudEndpointCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.CloudEndpoint"] + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + parameters: "_models.CloudEndpointCreateParameters", + **kwargs: Any + ) -> Optional["_models.CloudEndpoint"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.CloudEndpoint"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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') + _json = self._serialize.body(parameters, 'CloudEndpointCreateParameters') + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + cloud_endpoint_name=cloud_endpoint_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CloudEndpointCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('CloudEndpoint', pipeline_response) if response.status_code == 202: @@ -111,23 +545,26 @@ def _create_initial( response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}'} # type: ignore + + @distributed_trace def begin_create( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - cloud_endpoint_name, # type: str - parameters, # type: "_models.CloudEndpointCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.CloudEndpoint"] + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + parameters: "_models.CloudEndpointCreateParameters", + **kwargs: Any + ) -> LROPoller["_models.CloudEndpoint"]: """Create a new CloudEndpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -142,15 +579,19 @@ def begin_create( :type parameters: ~azure.mgmt.storagesync.models.CloudEndpointCreateParameters :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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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 CloudEndpoint 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 CloudEndpoint or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storagesync.models.CloudEndpoint] - :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.CloudEndpoint"] lro_delay = kwargs.pop( 'polling_interval', @@ -164,33 +605,25 @@ def begin_create( sync_group_name=sync_group_name, cloud_endpoint_name=cloud_endpoint_name, parameters=parameters, + 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_headers = {} response = pipeline_response.http_response response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('CloudEndpoint', pipeline_response) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, '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: @@ -202,17 +635,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - cloud_endpoint_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CloudEndpoint" + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + **kwargs: Any + ) -> "_models.CloudEndpoint": """Get a given CloudEndpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -233,97 +667,79 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + cloud_endpoint_name=cloud_endpoint_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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('CloudEndpoint', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}'} # type: ignore + def _delete_initial( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - cloud_endpoint_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + cloud_endpoint_name=cloud_endpoint_name, + 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 if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if response.status_code == 202: response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) @@ -331,21 +747,23 @@ def _delete_initial( response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - cloud_endpoint_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Delete a given CloudEndpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -358,15 +776,17 @@ def begin_delete( :type cloud_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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', @@ -382,23 +802,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 = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, '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: @@ -410,16 +821,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.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}'} # type: ignore + @distributed_trace def list_by_sync_group( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.CloudEndpointArray"] + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + **kwargs: Any + ) -> Iterable["_models.CloudEndpointArray"]: """Get a CloudEndpoint List. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -438,37 +850,35 @@ def list_by_sync_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_sync_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sync_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + template_url=self.list_by_sync_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_sync_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_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('CloudEndpointArray', pipeline_response) + deserialized = self._deserialize("CloudEndpointArray", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -481,12 +891,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -494,81 +905,72 @@ def get_next(next_link=None): def _pre_backup_initial( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - cloud_endpoint_name, # type: str - parameters, # type: "_models.BackupRequest" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + parameters: "_models.BackupRequest", + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._pre_backup_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'BackupRequest') - # 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') + request = build_pre_backup_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + cloud_endpoint_name=cloud_endpoint_name, + content_type=content_type, + json=_json, + template_url=self._pre_backup_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BackupRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) _pre_backup_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/prebackup'} # type: ignore + + @distributed_trace def begin_pre_backup( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - cloud_endpoint_name, # type: str - parameters, # type: "_models.BackupRequest" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + parameters: "_models.BackupRequest", + **kwargs: Any + ) -> LROPoller[None]: """Pre Backup a given CloudEndpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -583,15 +985,18 @@ def begin_pre_backup( :type parameters: ~azure.mgmt.storagesync.models.BackupRequest :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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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] + 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[None] lro_delay = kwargs.pop( 'polling_interval', @@ -605,26 +1010,18 @@ def begin_pre_backup( sync_group_name=sync_group_name, cloud_endpoint_name=cloud_endpoint_name, parameters=parameters, + 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): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, '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: @@ -636,88 +1033,81 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_pre_backup.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/prebackup'} # type: ignore def _post_backup_initial( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - cloud_endpoint_name, # type: str - parameters, # type: "_models.BackupRequest" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.PostBackupResponse"] + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + parameters: "_models.BackupRequest", + **kwargs: Any + ) -> Optional["_models.PostBackupResponse"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PostBackupResponse"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._post_backup_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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') + _json = self._serialize.body(parameters, 'BackupRequest') + + request = build_post_backup_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + cloud_endpoint_name=cloud_endpoint_name, + content_type=content_type, + json=_json, + template_url=self._post_backup_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BackupRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('PostBackupResponse', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _post_backup_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/postbackup'} # type: ignore + + @distributed_trace def begin_post_backup( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - cloud_endpoint_name, # type: str - parameters, # type: "_models.BackupRequest" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.PostBackupResponse"] + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + parameters: "_models.BackupRequest", + **kwargs: Any + ) -> LROPoller["_models.PostBackupResponse"]: """Post Backup a given CloudEndpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -732,15 +1122,19 @@ def begin_post_backup( :type parameters: ~azure.mgmt.storagesync.models.BackupRequest :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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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 PostBackupResponse 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 PostBackupResponse or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storagesync.models.PostBackupResponse] - :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.PostBackupResponse"] lro_delay = kwargs.pop( 'polling_interval', @@ -754,12 +1148,11 @@ def begin_post_backup( sync_group_name=sync_group_name, cloud_endpoint_name=cloud_endpoint_name, parameters=parameters, + 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_headers = {} @@ -767,21 +1160,14 @@ def get_long_running_output(pipeline_response): response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('PostBackupResponse', pipeline_response) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, '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: @@ -793,80 +1179,71 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_post_backup.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/postbackup'} # type: ignore def _pre_restore_initial( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - cloud_endpoint_name, # type: str - parameters, # type: "_models.PreRestoreRequest" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + parameters: "_models.PreRestoreRequest", + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._pre_restore_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PreRestoreRequest') - # 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') + request = build_pre_restore_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + cloud_endpoint_name=cloud_endpoint_name, + content_type=content_type, + json=_json, + template_url=self._pre_restore_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PreRestoreRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) _pre_restore_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/prerestore'} # type: ignore + + @distributed_trace def begin_pre_restore( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - cloud_endpoint_name, # type: str - parameters, # type: "_models.PreRestoreRequest" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + parameters: "_models.PreRestoreRequest", + **kwargs: Any + ) -> LROPoller[None]: """Pre Restore a given CloudEndpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -881,15 +1258,18 @@ def begin_pre_restore( :type parameters: ~azure.mgmt.storagesync.models.PreRestoreRequest :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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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] + 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[None] lro_delay = kwargs.pop( 'polling_interval', @@ -903,26 +1283,18 @@ def begin_pre_restore( sync_group_name=sync_group_name, cloud_endpoint_name=cloud_endpoint_name, parameters=parameters, + 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): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, '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: @@ -934,17 +1306,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_pre_restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/prerestore'} # type: ignore + @distributed_trace def restoreheartbeat( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - cloud_endpoint_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + **kwargs: Any + ) -> None: """Restore Heartbeat a given CloudEndpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -965,118 +1338,100 @@ def restoreheartbeat( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.restoreheartbeat.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_restoreheartbeat_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + cloud_endpoint_name=cloud_endpoint_name, + template_url=self.restoreheartbeat.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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) restoreheartbeat.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/restoreheartbeat'} # type: ignore + def _post_restore_initial( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - cloud_endpoint_name, # type: str - parameters, # type: "_models.PostRestoreRequest" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + parameters: "_models.PostRestoreRequest", + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._post_restore_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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') + _json = self._serialize.body(parameters, 'PostRestoreRequest') + + request = build_post_restore_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + cloud_endpoint_name=cloud_endpoint_name, + content_type=content_type, + json=_json, + template_url=self._post_restore_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PostRestoreRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) _post_restore_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/postrestore'} # type: ignore + + @distributed_trace def begin_post_restore( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - cloud_endpoint_name, # type: str - parameters, # type: "_models.PostRestoreRequest" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + parameters: "_models.PostRestoreRequest", + **kwargs: Any + ) -> LROPoller[None]: """Post Restore a given CloudEndpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -1091,15 +1446,18 @@ def begin_post_restore( :type parameters: ~azure.mgmt.storagesync.models.PostRestoreRequest :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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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] + 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[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1113,26 +1471,18 @@ def begin_post_restore( sync_group_name=sync_group_name, cloud_endpoint_name=cloud_endpoint_name, parameters=parameters, + 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): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, '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: @@ -1144,80 +1494,71 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_post_restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/postrestore'} # type: ignore def _trigger_change_detection_initial( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - cloud_endpoint_name, # type: str - parameters, # type: "_models.TriggerChangeDetectionParameters" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + parameters: "_models.TriggerChangeDetectionParameters", + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._trigger_change_detection_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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') + _json = self._serialize.body(parameters, 'TriggerChangeDetectionParameters') + + request = build_trigger_change_detection_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + cloud_endpoint_name=cloud_endpoint_name, + content_type=content_type, + json=_json, + template_url=self._trigger_change_detection_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TriggerChangeDetectionParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) _trigger_change_detection_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/triggerChangeDetection'} # type: ignore + + @distributed_trace def begin_trigger_change_detection( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - cloud_endpoint_name, # type: str - parameters, # type: "_models.TriggerChangeDetectionParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + cloud_endpoint_name: str, + parameters: "_models.TriggerChangeDetectionParameters", + **kwargs: Any + ) -> LROPoller[None]: """Triggers detection of changes performed on Azure File share connected to the specified Azure File Sync Cloud Endpoint. @@ -1233,15 +1574,18 @@ def begin_trigger_change_detection( :type parameters: ~azure.mgmt.storagesync.models.TriggerChangeDetectionParameters :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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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] + 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[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1255,26 +1599,18 @@ def begin_trigger_change_detection( sync_group_name=sync_group_name, cloud_endpoint_name=cloud_endpoint_name, parameters=parameters, + 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): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'cloudEndpointName': self._serialize.url("cloud_endpoint_name", cloud_endpoint_name, '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: @@ -1286,4 +1622,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_trigger_change_detection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/triggerChangeDetection'} # type: ignore diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_microsoft_storage_sync_operations.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_microsoft_storage_sync_operations.py new file mode 100644 index 000000000000..63045272bd08 --- /dev/null +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_microsoft_storage_sync_operations.py @@ -0,0 +1,118 @@ +# 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, 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 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_location_operation_status_request( + subscription_id: str, + location_name: str, + operation_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.StorageSync/locations/{locationName}/operations/{operationId}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "locationName": _SERIALIZER.url("location_name", location_name, '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 MicrosoftStorageSyncOperationsMixin(object): + + @distributed_trace + def location_operation_status( + self, + location_name: str, + operation_id: str, + **kwargs: Any + ) -> "_models.LocationOperationStatus": + """Get Operation status. + + :param location_name: The desired region to obtain information from. + :type location_name: str + :param operation_id: operation Id. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocationOperationStatus, or the result of cls(response) + :rtype: ~azure.mgmt.storagesync.models.LocationOperationStatus + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationOperationStatus"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_location_operation_status_request( + subscription_id=self._config.subscription_id, + location_name=location_name, + operation_id=operation_id, + template_url=self.location_operation_status.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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) + response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + + deserialized = self._deserialize('LocationOperationStatus', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + location_operation_status.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.StorageSync/locations/{locationName}/operations/{operationId}'} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_operation_status_operations.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_operation_status_operations.py index 9570efb48cc9..f596a4cd4681 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_operation_status_operations.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_operation_status_operations.py @@ -5,22 +5,63 @@ # 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, + resource_group_name: str, + location_name: str, + workflow_id: str, + operation_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/locations/{locationName}/workflows/{workflowId}/operations/{operationId}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "workflowId": _SERIALIZER.url("workflow_id", workflow_id, '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 OperationStatusOperations(object): """OperationStatusOperations operations. @@ -44,15 +85,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - location_name, # type: str - workflow_id, # type: str - operation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.OperationStatus" + resource_group_name: str, + location_name: str, + workflow_id: str, + operation_id: str, + **kwargs: Any + ) -> "_models.OperationStatus": """Get Operation status. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -73,44 +114,37 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'workflowId': self._serialize.url("workflow_id", workflow_id, '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, + resource_group_name=resource_group_name, + location_name=location_name, + workflow_id=workflow_id, + 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 = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('OperationStatus', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/locations/{locationName}/workflows/{workflowId}/operations/{operationId}'} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_operations.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_operations.py index 56933c8f386d..8f5f08e6980d 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/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 = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.StorageSync/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,15 +72,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationEntityListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationEntityListResult"]: """Lists all of the available Storage Sync Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationEntityListResult or the result of cls(response) + :return: An iterator like instance of either OperationEntityListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storagesync.models.OperationEntityListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -62,30 +90,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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('OperationEntityListResult', pipeline_response) + deserialized = self._deserialize("OperationEntityListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +123,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_private_endpoint_connections_operations.py index 8c5c63c59860..ad698b9cbe3b 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_private_endpoint_connections_operations.py @@ -5,25 +5,183 @@ # 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_get_request( + resource_group_name: str, + storage_sync_service_name: str, + subscription_id: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/privateEndpointConnections/{privateEndpointConnectionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, '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_request_initial( + resource_group_name: str, + storage_sync_service_name: str, + subscription_id: str, + private_endpoint_connection_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/privateEndpointConnections/{privateEndpointConnectionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, '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] + 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_delete_request_initial( + resource_group_name: str, + storage_sync_service_name: str, + subscription_id: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/privateEndpointConnections/{privateEndpointConnectionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, '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_list_by_storage_sync_service_request( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/privateEndpointConnections') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, '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 PrivateEndpointConnectionsOperations(object): """PrivateEndpointConnectionsOperations operations. @@ -47,14 +205,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" + resource_group_name: str, + storage_sync_service_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> "_models.PrivateEndpointConnection": """Gets the specified private endpoint connection associated with the storage sync service. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -75,34 +233,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -111,59 +259,49 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + def _create_initial( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - private_endpoint_connection_name, # type: str - properties, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.PrivateEndpointConnection"] + resource_group_name: str, + storage_sync_service_name: str, + private_endpoint_connection_name: str, + properties: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> Optional["_models.PrivateEndpointConnection"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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') + _json = self._serialize.body(properties, 'PrivateEndpointConnection') + + request = build_create_request_initial( + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'PrivateEndpointConnection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -173,22 +311,25 @@ def _create_initial( response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def begin_create( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - private_endpoint_connection_name, # type: str - properties, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.PrivateEndpointConnection"] + resource_group_name: str, + storage_sync_service_name: str, + private_endpoint_connection_name: str, + properties: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> LROPoller["_models.PrivateEndpointConnection"]: """Update the state of specified private endpoint connection associated with the storage sync service. @@ -204,15 +345,19 @@ def begin_create( :type properties: ~azure.mgmt.storagesync.models.PrivateEndpointConnection :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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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 PrivateEndpointConnection 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 PrivateEndpointConnection or the result + of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storagesync.models.PrivateEndpointConnection] - :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.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -225,28 +370,21 @@ def begin_create( storage_sync_service_name=storage_sync_service_name, private_endpoint_connection_name=private_endpoint_connection_name, properties=properties, + 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('PrivateEndpointConnection', 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', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, '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: @@ -258,50 +396,39 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + storage_sync_service_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + 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 if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: @@ -310,20 +437,22 @@ def _delete_initial( response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + storage_sync_service_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes the specified private endpoint connection associated with the storage sync service. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -336,15 +465,17 @@ def begin_delete( :type private_endpoint_connection_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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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', @@ -359,22 +490,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', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, '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: @@ -386,15 +509,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.StorageSync/storageSyncServices/{storageSyncServiceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + @distributed_trace def list_by_storage_sync_service( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PrivateEndpointConnectionListResult"] + resource_group_name: str, + storage_sync_service_name: str, + **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: """Get a PrivateEndpointConnection List. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -402,8 +526,10 @@ def list_by_storage_sync_service( :param storage_sync_service_name: Name of Storage Sync Service resource. :type storage_sync_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storagesync.models.PrivateEndpointConnectionListResult] + :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storagesync.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] @@ -411,36 +537,33 @@ def list_by_storage_sync_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_storage_sync_service.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_storage_sync_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + template_url=self.list_by_storage_sync_service.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_storage_sync_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_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('PrivateEndpointConnectionListResult', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -453,12 +576,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_private_link_resources_operations.py index 28a2bdf10300..ef1fb724711e 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_private_link_resources_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_list_by_storage_sync_service_request( + resource_group_name: str, + storage_sync_service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/privateLinkResources') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + 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 PrivateLinkResourcesOperations(object): """PrivateLinkResourcesOperations operations. @@ -44,13 +81,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_storage_sync_service( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateLinkResourceListResult" + resource_group_name: str, + storage_sync_service_name: str, + **kwargs: Any + ) -> "_models.PrivateLinkResourceListResult": """Gets the private link resources that need to be created for a storage sync service. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -68,27 +105,17 @@ def list_by_storage_sync_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.list_by_storage_sync_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_by_storage_sync_service_request( + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_storage_sync_service.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 @@ -102,4 +129,6 @@ def list_by_storage_sync_service( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_storage_sync_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/privateLinkResources'} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_registered_servers_operations.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_registered_servers_operations.py index 8d6904097453..1188407260da 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_registered_servers_operations.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_registered_servers_operations.py @@ -5,25 +5,229 @@ # 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_by_storage_sync_service_request( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, '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_get_request( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + server_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers/{serverId}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "serverId": _SERIALIZER.url("server_id", server_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_request_initial( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + server_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers/{serverId}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "serverId": _SERIALIZER.url("server_id", server_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] + 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_delete_request_initial( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + server_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers/{serverId}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "serverId": _SERIALIZER.url("server_id", server_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_trigger_rollover_request_initial( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + server_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers/{serverId}/triggerRollover') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "serverId": _SERIALIZER.url("server_id", server_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] + 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class RegisteredServersOperations(object): """RegisteredServersOperations operations. @@ -47,13 +251,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_storage_sync_service( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RegisteredServerArray"] + resource_group_name: str, + storage_sync_service_name: str, + **kwargs: Any + ) -> Iterable["_models.RegisteredServerArray"]: """Get a given registered server list. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -61,7 +265,8 @@ def list_by_storage_sync_service( :param storage_sync_service_name: Name of Storage Sync Service resource. :type storage_sync_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegisteredServerArray or the result of cls(response) + :return: An iterator like instance of either RegisteredServerArray or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storagesync.models.RegisteredServerArray] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -70,36 +275,33 @@ def list_by_storage_sync_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_storage_sync_service.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_storage_sync_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + template_url=self.list_by_storage_sync_service.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_storage_sync_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_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('RegisteredServerArray', pipeline_response) + deserialized = self._deserialize("RegisteredServerArray", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -112,25 +314,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_storage_sync_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - server_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RegisteredServer" + resource_group_name: str, + storage_sync_service_name: str, + server_id: str, + **kwargs: Any + ) -> "_models.RegisteredServer": """Get a given registered server. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -149,101 +352,83 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'serverId': self._serialize.url("server_id", server_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, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + server_id=server_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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('RegisteredServer', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers/{serverId}'} # type: ignore + def _create_initial( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - server_id, # type: str - parameters, # type: "_models.RegisteredServerCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RegisteredServer"] + resource_group_name: str, + storage_sync_service_name: str, + server_id: str, + parameters: "_models.RegisteredServerCreateParameters", + **kwargs: Any + ) -> Optional["_models.RegisteredServer"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RegisteredServer"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'serverId': self._serialize.url("server_id", server_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegisteredServerCreateParameters') - # 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') + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + server_id=server_id, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegisteredServerCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('RegisteredServer', pipeline_response) if response.status_code == 202: @@ -251,22 +436,25 @@ def _create_initial( response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers/{serverId}'} # type: ignore + + @distributed_trace def begin_create( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - server_id, # type: str - parameters, # type: "_models.RegisteredServerCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.RegisteredServer"] + resource_group_name: str, + storage_sync_service_name: str, + server_id: str, + parameters: "_models.RegisteredServerCreateParameters", + **kwargs: Any + ) -> LROPoller["_models.RegisteredServer"]: """Add a new registered server. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -279,15 +467,19 @@ def begin_create( :type parameters: ~azure.mgmt.storagesync.models.RegisteredServerCreateParameters :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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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 RegisteredServer 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 RegisteredServer or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storagesync.models.RegisteredServer] - :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.RegisteredServer"] lro_delay = kwargs.pop( 'polling_interval', @@ -300,32 +492,25 @@ def begin_create( storage_sync_service_name=storage_sync_service_name, server_id=server_id, parameters=parameters, + 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_headers = {} response = pipeline_response.http_response response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('RegisteredServer', pipeline_response) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'serverId': self._serialize.url("server_id", server_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: @@ -337,74 +522,66 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers/{serverId}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - server_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + storage_sync_service_name: str, + server_id: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'serverId': self._serialize.url("server_id", server_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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + server_id=server_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 if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers/{serverId}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - server_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + storage_sync_service_name: str, + server_id: str, + **kwargs: Any + ) -> LROPoller[None]: """Delete the given registered server. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -415,15 +592,17 @@ def begin_delete( :type server_id: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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', @@ -438,22 +617,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 = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'serverId': self._serialize.url("server_id", server_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: @@ -465,81 +636,73 @@ 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.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers/{serverId}'} # type: ignore def _trigger_rollover_initial( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - server_id, # type: str - parameters, # type: "_models.TriggerRolloverRequest" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + storage_sync_service_name: str, + server_id: str, + parameters: "_models.TriggerRolloverRequest", + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._trigger_rollover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'serverId': self._serialize.url("server_id", server_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') + 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') + _json = self._serialize.body(parameters, 'TriggerRolloverRequest') + + request = build_trigger_rollover_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + server_id=server_id, + content_type=content_type, + json=_json, + template_url=self._trigger_rollover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TriggerRolloverRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) _trigger_rollover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers/{serverId}/triggerRollover'} # type: ignore + + @distributed_trace def begin_trigger_rollover( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - server_id, # type: str - parameters, # type: "_models.TriggerRolloverRequest" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + storage_sync_service_name: str, + server_id: str, + parameters: "_models.TriggerRolloverRequest", + **kwargs: Any + ) -> LROPoller[None]: """Triggers Server certificate rollover. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -552,15 +715,18 @@ def begin_trigger_rollover( :type parameters: ~azure.mgmt.storagesync.models.TriggerRolloverRequest :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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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] + 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[None] lro_delay = kwargs.pop( 'polling_interval', @@ -573,25 +739,18 @@ def begin_trigger_rollover( storage_sync_service_name=storage_sync_service_name, server_id=server_id, parameters=parameters, + 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): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'serverId': self._serialize.url("server_id", server_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: @@ -603,4 +762,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_trigger_rollover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers/{serverId}/triggerRollover'} # type: ignore diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_server_endpoints_operations.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_server_endpoints_operations.py index 32cd79267ddb..db73353a8cd4 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_server_endpoints_operations.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_server_endpoints_operations.py @@ -5,25 +5,287 @@ # 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_create_request_initial( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + server_endpoint_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "serverEndpointName": _SERIALIZER.url("server_endpoint_name", server_endpoint_name, '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] + 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_initial( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + server_endpoint_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "serverEndpointName": _SERIALIZER.url("server_endpoint_name", server_endpoint_name, '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] + 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_get_request( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + server_endpoint_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "serverEndpointName": _SERIALIZER.url("server_endpoint_name", server_endpoint_name, '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( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + server_endpoint_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "serverEndpointName": _SERIALIZER.url("server_endpoint_name", server_endpoint_name, '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_list_by_sync_group_request( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, '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_recall_action_request_initial( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + server_endpoint_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}/recallAction') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, 'str'), + "serverEndpointName": _SERIALIZER.url("server_endpoint_name", server_endpoint_name, '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] + 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class ServerEndpointsOperations(object): """ServerEndpointsOperations operations. @@ -49,60 +311,49 @@ def __init__(self, client, config, serializer, deserializer): def _create_initial( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - server_endpoint_name, # type: str - parameters, # type: "_models.ServerEndpointCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ServerEndpoint"] + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + server_endpoint_name: str, + parameters: "_models.ServerEndpointCreateParameters", + **kwargs: Any + ) -> Optional["_models.ServerEndpoint"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerEndpoint"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'serverEndpointName': self._serialize.url("server_endpoint_name", server_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ServerEndpointCreateParameters') - # 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') + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + server_endpoint_name=server_endpoint_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServerEndpointCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('ServerEndpoint', pipeline_response) if response.status_code == 202: @@ -110,23 +361,26 @@ def _create_initial( response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}'} # type: ignore + + @distributed_trace def begin_create( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - server_endpoint_name, # type: str - parameters, # type: "_models.ServerEndpointCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ServerEndpoint"] + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + server_endpoint_name: str, + parameters: "_models.ServerEndpointCreateParameters", + **kwargs: Any + ) -> LROPoller["_models.ServerEndpoint"]: """Create a new ServerEndpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -141,15 +395,19 @@ def begin_create( :type parameters: ~azure.mgmt.storagesync.models.ServerEndpointCreateParameters :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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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 ServerEndpoint 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 ServerEndpoint or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storagesync.models.ServerEndpoint] - :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.ServerEndpoint"] lro_delay = kwargs.pop( 'polling_interval', @@ -163,33 +421,25 @@ def begin_create( sync_group_name=sync_group_name, server_endpoint_name=server_endpoint_name, parameters=parameters, + 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_headers = {} response = pipeline_response.http_response response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('ServerEndpoint', pipeline_response) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'serverEndpointName': self._serialize.url("server_endpoint_name", server_endpoint_name, '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: @@ -201,67 +451,57 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - server_endpoint_name, # type: str - parameters=None, # type: Optional["_models.ServerEndpointUpdateParameters"] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ServerEndpoint"] + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + server_endpoint_name: str, + parameters: Optional["_models.ServerEndpointUpdateParameters"] = None, + **kwargs: Any + ) -> Optional["_models.ServerEndpoint"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerEndpoint"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'serverEndpointName': self._serialize.url("server_endpoint_name", server_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: - body_content = self._serialize.body(parameters, 'ServerEndpointUpdateParameters') + _json = self._serialize.body(parameters, 'ServerEndpointUpdateParameters') 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_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + server_endpoint_name=server_endpoint_name, + content_type=content_type, + json=_json, + template_url=self._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 if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('ServerEndpoint', pipeline_response) if response.status_code == 202: @@ -269,23 +509,26 @@ def _update_initial( response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - server_endpoint_name, # type: str - parameters=None, # type: Optional["_models.ServerEndpointUpdateParameters"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ServerEndpoint"] + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + server_endpoint_name: str, + parameters: Optional["_models.ServerEndpointUpdateParameters"] = None, + **kwargs: Any + ) -> LROPoller["_models.ServerEndpoint"]: """Patch a given ServerEndpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -300,15 +543,19 @@ def begin_update( :type parameters: ~azure.mgmt.storagesync.models.ServerEndpointUpdateParameters :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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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 ServerEndpoint 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 ServerEndpoint or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storagesync.models.ServerEndpoint] - :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.ServerEndpoint"] lro_delay = kwargs.pop( 'polling_interval', @@ -322,33 +569,25 @@ def begin_update( sync_group_name=sync_group_name, server_endpoint_name=server_endpoint_name, parameters=parameters, + 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_headers = {} response = pipeline_response.http_response response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('ServerEndpoint', pipeline_response) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'serverEndpointName': self._serialize.url("server_endpoint_name", server_endpoint_name, '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: @@ -360,17 +599,18 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - server_endpoint_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ServerEndpoint" + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + server_endpoint_name: str, + **kwargs: Any + ) -> "_models.ServerEndpoint": """Get a ServerEndpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -391,117 +631,101 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'serverEndpointName': self._serialize.url("server_endpoint_name", server_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + server_endpoint_name=server_endpoint_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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('ServerEndpoint', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}'} # type: ignore + def _delete_initial( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - server_endpoint_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + server_endpoint_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'serverEndpointName': self._serialize.url("server_endpoint_name", server_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + server_endpoint_name=server_endpoint_name, + 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 if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - server_endpoint_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + server_endpoint_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Delete a given ServerEndpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -514,15 +738,17 @@ def begin_delete( :type server_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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', @@ -538,23 +764,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 = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'serverEndpointName': self._serialize.url("server_endpoint_name", server_endpoint_name, '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: @@ -566,16 +783,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.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}'} # type: ignore + @distributed_trace def list_by_sync_group( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ServerEndpointArray"] + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + **kwargs: Any + ) -> Iterable["_models.ServerEndpointArray"]: """Get a ServerEndpoint list. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -594,37 +812,35 @@ def list_by_sync_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_sync_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sync_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + template_url=self.list_by_sync_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_sync_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_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('ServerEndpointArray', pipeline_response) + deserialized = self._deserialize("ServerEndpointArray", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -637,12 +853,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -650,80 +867,71 @@ def get_next(next_link=None): def _recall_action_initial( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - server_endpoint_name, # type: str - parameters, # type: "_models.RecallActionParameters" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + server_endpoint_name: str, + parameters: "_models.RecallActionParameters", + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._recall_action_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'serverEndpointName': self._serialize.url("server_endpoint_name", server_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RecallActionParameters') - # 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') + request = build_recall_action_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + server_endpoint_name=server_endpoint_name, + content_type=content_type, + json=_json, + template_url=self._recall_action_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RecallActionParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) _recall_action_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}/recallAction'} # type: ignore + + @distributed_trace def begin_recall_action( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - server_endpoint_name, # type: str - parameters, # type: "_models.RecallActionParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + server_endpoint_name: str, + parameters: "_models.RecallActionParameters", + **kwargs: Any + ) -> LROPoller[None]: """Recall a server endpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -738,15 +946,18 @@ def begin_recall_action( :type parameters: ~azure.mgmt.storagesync.models.RecallActionParameters :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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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] + 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[None] lro_delay = kwargs.pop( 'polling_interval', @@ -760,26 +971,18 @@ def begin_recall_action( sync_group_name=sync_group_name, server_endpoint_name=server_endpoint_name, parameters=parameters, + 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): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'serverEndpointName': self._serialize.url("server_endpoint_name", server_endpoint_name, '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: @@ -791,4 +994,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_recall_action.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}/recallAction'} # type: ignore diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_storage_sync_services_operations.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_storage_sync_services_operations.py index fad2c652c330..3dda9e9b4b7d 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_storage_sync_services_operations.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_storage_sync_services_operations.py @@ -5,25 +5,292 @@ # 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_check_name_availability_request( + location_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.StorageSync/locations/{locationName}/checkNameAvailability') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_create_request_initial( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, '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] + 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_get_request( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, '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_update_request_initial( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, '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] + 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_delete_request_initial( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, '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_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + 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_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.StorageSync/storageSyncServices') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + 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 StorageSyncServicesOperations(object): """StorageSyncServicesOperations operations. @@ -47,13 +314,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def check_name_availability( self, - location_name, # type: str - parameters, # type: "_models.CheckNameAvailabilityParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.CheckNameAvailabilityResult" + location_name: str, + parameters: "_models.CheckNameAvailabilityParameters", + **kwargs: Any + ) -> "_models.CheckNameAvailabilityResult": """Check the give namespace name availability. :param location_name: The desired region for the name check. @@ -70,31 +337,21 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'locationName': self._serialize.url("location_name", location_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CheckNameAvailabilityParameters') - # 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') + request = build_check_name_availability_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailabilityParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -108,57 +365,47 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.StorageSync/locations/{locationName}/checkNameAvailability'} # type: ignore + def _create_initial( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - parameters, # type: "_models.StorageSyncServiceCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.StorageSyncService"] + resource_group_name: str, + storage_sync_service_name: str, + parameters: "_models.StorageSyncServiceCreateParameters", + **kwargs: Any + ) -> Optional["_models.StorageSyncService"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageSyncService"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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') + _json = self._serialize.body(parameters, 'StorageSyncServiceCreateParameters') + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'StorageSyncServiceCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('StorageSyncService', pipeline_response) @@ -168,21 +415,24 @@ def _create_initial( response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}'} # type: ignore + + @distributed_trace def begin_create( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - parameters, # type: "_models.StorageSyncServiceCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.StorageSyncService"] + resource_group_name: str, + storage_sync_service_name: str, + parameters: "_models.StorageSyncServiceCreateParameters", + **kwargs: Any + ) -> LROPoller["_models.StorageSyncService"]: """Create a new StorageSyncService. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -193,15 +443,19 @@ def begin_create( :type parameters: ~azure.mgmt.storagesync.models.StorageSyncServiceCreateParameters :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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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 StorageSyncService 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 StorageSyncService or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storagesync.models.StorageSyncService] - :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.StorageSyncService"] lro_delay = kwargs.pop( 'polling_interval', @@ -213,27 +467,21 @@ def begin_create( resource_group_name=resource_group_name, storage_sync_service_name=storage_sync_service_name, parameters=parameters, + 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('StorageSyncService', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, '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: @@ -245,15 +493,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.StorageSyncService" + resource_group_name: str, + storage_sync_service_name: str, + **kwargs: Any + ) -> "_models.StorageSyncService": """Get a given StorageSyncService. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -270,101 +519,83 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('StorageSyncService', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}'} # type: ignore + def _update_initial( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - parameters=None, # type: Optional["_models.StorageSyncServiceUpdateParameters"] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.StorageSyncService"] + resource_group_name: str, + storage_sync_service_name: str, + parameters: Optional["_models.StorageSyncServiceUpdateParameters"] = None, + **kwargs: Any + ) -> Optional["_models.StorageSyncService"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageSyncService"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: - body_content = self._serialize.body(parameters, 'StorageSyncServiceUpdateParameters') + _json = self._serialize.body(parameters, 'StorageSyncServiceUpdateParameters') 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_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + content_type=content_type, + json=_json, + template_url=self._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 if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('StorageSyncService', pipeline_response) if response.status_code == 202: @@ -373,21 +604,24 @@ def _update_initial( response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - parameters=None, # type: Optional["_models.StorageSyncServiceUpdateParameters"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.StorageSyncService"] + resource_group_name: str, + storage_sync_service_name: str, + parameters: Optional["_models.StorageSyncServiceUpdateParameters"] = None, + **kwargs: Any + ) -> LROPoller["_models.StorageSyncService"]: """Patch a given StorageSyncService. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -398,15 +632,19 @@ def begin_update( :type parameters: ~azure.mgmt.storagesync.models.StorageSyncServiceUpdateParameters :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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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 StorageSyncService 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 StorageSyncService or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storagesync.models.StorageSyncService] - :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.StorageSyncService"] lro_delay = kwargs.pop( 'polling_interval', @@ -418,31 +656,25 @@ def begin_update( resource_group_name=resource_group_name, storage_sync_service_name=storage_sync_service_name, parameters=parameters, + 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_headers = {} response = pipeline_response.http_response response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('StorageSyncService', pipeline_response) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, '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: @@ -454,53 +686,43 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + storage_sync_service_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + 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 if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if response.status_code == 202: response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) @@ -508,19 +730,21 @@ def _delete_initial( response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + storage_sync_service_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Delete a given StorageSyncService. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -529,15 +753,17 @@ def begin_delete( :type storage_sync_service_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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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', @@ -551,21 +777,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 = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, '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: @@ -577,20 +796,22 @@ 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.StorageSync/storageSyncServices/{storageSyncServiceName}'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.StorageSyncServiceArray"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.StorageSyncServiceArray"]: """Get a StorageSyncService list by Resource group name. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSyncServiceArray or the result of cls(response) + :return: An iterator like instance of either StorageSyncServiceArray or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storagesync.models.StorageSyncServiceArray] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -599,35 +820,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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 = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + 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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_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('StorageSyncServiceArray', pipeline_response) + deserialized = self._deserialize("StorageSyncServiceArray", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -640,26 +857,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.StorageSyncServiceArray"] + **kwargs: Any + ) -> Iterable["_models.StorageSyncServiceArray"]: """Get a StorageSyncService list by subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSyncServiceArray or the result of cls(response) + :return: An iterator like instance of either StorageSyncServiceArray or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storagesync.models.StorageSyncServiceArray] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -668,34 +887,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.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_subscription_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('StorageSyncServiceArray', pipeline_response) + deserialized = self._deserialize("StorageSyncServiceArray", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -708,12 +922,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_sync_groups_operations.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_sync_groups_operations.py index 2747ab44058a..b0d2a588d87b 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_sync_groups_operations.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_sync_groups_operations.py @@ -5,23 +5,181 @@ # 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') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_storage_sync_service_request( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, '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_request( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, '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] + 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_get_request( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, '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( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, '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 + ) class SyncGroupsOperations(object): """SyncGroupsOperations operations. @@ -45,13 +203,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_storage_sync_service( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SyncGroupArray"] + resource_group_name: str, + storage_sync_service_name: str, + **kwargs: Any + ) -> Iterable["_models.SyncGroupArray"]: """Get a SyncGroup List. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -68,36 +226,33 @@ def list_by_storage_sync_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_storage_sync_service.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_storage_sync_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + template_url=self.list_by_storage_sync_service.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_storage_sync_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_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('SyncGroupArray', pipeline_response) + deserialized = self._deserialize("SyncGroupArray", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,26 +265,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_storage_sync_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups'} # type: ignore + @distributed_trace def create( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - parameters, # type: "_models.SyncGroupCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.SyncGroup" + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + parameters: "_models.SyncGroupCreateParameters", + **kwargs: Any + ) -> "_models.SyncGroup": """Create a new SyncGroup. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -150,60 +306,53 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SyncGroupCreateParameters') - # 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') + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SyncGroupCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('SyncGroup', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SyncGroup" + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + **kwargs: Any + ) -> "_models.SyncGroup": """Get a given SyncGroup. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -222,55 +371,48 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('SyncGroup', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - sync_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + storage_sync_service_name: str, + sync_group_name: str, + **kwargs: Any + ) -> None: """Delete a given SyncGroup. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -289,42 +431,34 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + sync_group_name=sync_group_name, + template_url=self.delete.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 if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}'} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_workflows_operations.py b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_workflows_operations.py index 0a90d5cbecc6..da6ff7db91fa 100644 --- a/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_workflows_operations.py +++ b/sdk/storage/azure-mgmt-storagesync/azure/mgmt/storagesync/operations/_workflows_operations.py @@ -5,23 +5,134 @@ # 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_by_storage_sync_service_request( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/workflows') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, '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_get_request( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + workflow_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/workflows/{workflowId}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "workflowId": _SERIALIZER.url("workflow_id", workflow_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_abort_request( + subscription_id: str, + resource_group_name: str, + storage_sync_service_name: str, + workflow_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/workflows/{workflowId}/abort') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "storageSyncServiceName": _SERIALIZER.url("storage_sync_service_name", storage_sync_service_name, 'str'), + "workflowId": _SERIALIZER.url("workflow_id", workflow_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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class WorkflowsOperations(object): """WorkflowsOperations operations. @@ -45,13 +156,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_storage_sync_service( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkflowArray"] + resource_group_name: str, + storage_sync_service_name: str, + **kwargs: Any + ) -> Iterable["_models.WorkflowArray"]: """Get a Workflow List. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -68,36 +179,33 @@ def list_by_storage_sync_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_storage_sync_service.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_storage_sync_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + template_url=self.list_by_storage_sync_service.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_storage_sync_service_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_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('WorkflowArray', pipeline_response) + deserialized = self._deserialize("WorkflowArray", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,25 +218,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_storage_sync_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/workflows'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - workflow_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Workflow" + resource_group_name: str, + storage_sync_service_name: str, + workflow_id: str, + **kwargs: Any + ) -> "_models.Workflow": """Get Workflows resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -147,55 +256,48 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'workflowId': self._serialize.url("workflow_id", workflow_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, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + workflow_id=workflow_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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + deserialized = self._deserialize('Workflow', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/workflows/{workflowId}'} # type: ignore + + @distributed_trace def abort( self, - resource_group_name, # type: str - storage_sync_service_name, # type: str - workflow_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + storage_sync_service_name: str, + workflow_id: str, + **kwargs: Any + ) -> None: """Abort the given workflow. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -214,41 +316,33 @@ def abort( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.abort.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'storageSyncServiceName': self._serialize.url("storage_sync_service_name", storage_sync_service_name, 'str'), - 'workflowId': self._serialize.url("workflow_id", workflow_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_abort_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + storage_sync_service_name=storage_sync_service_name, + workflow_id=workflow_id, + template_url=self.abort.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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, response) + error = self._deserialize.failsafe_deserialize(_models.StorageSyncError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-correlation-request-id']=self._deserialize('str', response.headers.get('x-ms-correlation-request-id')) + if cls: return cls(pipeline_response, None, response_headers) abort.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/workflows/{workflowId}/abort'} # type: ignore +