From aeeed86d56844c2343772f9bcc8d3bba8f81b36b Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Tue, 15 Apr 2025 03:16:46 +0000 Subject: [PATCH] code and test --- .../azure-mgmt-durabletask/CHANGELOG.md | 23 + .../azure-mgmt-durabletask/README.md | 2 +- .../azure-mgmt-durabletask/_meta.json | 4 +- .../apiview-properties.json | 11 +- .../azure/mgmt/durabletask/_client.py | 9 +- .../azure/mgmt/durabletask/_configuration.py | 4 +- .../azure/mgmt/durabletask/_model_base.py | 5 +- .../azure/mgmt/durabletask/_patch.py | 9 +- .../azure/mgmt/durabletask/_serialization.py | 26 +- .../azure/mgmt/durabletask/_validation.py | 50 + .../azure/mgmt/durabletask/_version.py | 2 +- .../azure/mgmt/durabletask/aio/_client.py | 9 +- .../mgmt/durabletask/aio/_configuration.py | 4 +- .../azure/mgmt/durabletask/aio/_patch.py | 9 +- .../durabletask/aio/operations/__init__.py | 2 + .../durabletask/aio/operations/_operations.py | 843 +++++++++++++- .../mgmt/durabletask/aio/operations/_patch.py | 9 +- .../azure/mgmt/durabletask/models/__init__.py | 8 + .../azure/mgmt/durabletask/models/_enums.py | 13 + .../azure/mgmt/durabletask/models/_models.py | 122 ++ .../azure/mgmt/durabletask/models/_patch.py | 9 +- .../mgmt/durabletask/operations/__init__.py | 2 + .../durabletask/operations/_operations.py | 1004 ++++++++++++++++- .../mgmt/durabletask/operations/_patch.py | 9 +- .../generated_samples/operations_list.py | 2 +- ...icies_create_or_replace_maximum_set_gen.py | 50 + ...tention_policies_delete_maximum_set_gen.py | 41 + .../retention_policies_get_maximum_set_gen.py | 42 + ...icies_list_by_scheduler_maximum_set_gen.py | 43 + ...tention_policies_update_maximum_set_gen.py | 51 + .../schedulers_create_or_update.py | 4 +- .../generated_samples/schedulers_delete.py | 2 +- .../generated_samples/schedulers_get.py | 2 +- .../schedulers_list_by_resource_group.py | 2 +- .../schedulers_list_by_subscription.py | 2 +- .../generated_samples/schedulers_update.py | 6 +- .../task_hubs_create_or_update.py | 2 +- .../generated_samples/task_hubs_delete.py | 4 +- .../generated_samples/task_hubs_get.py | 4 +- .../task_hubs_list_by_scheduler.py | 4 +- ...task_mgmt_retention_policies_operations.py | 108 ++ ...gmt_retention_policies_operations_async.py | 115 ++ .../azure-mgmt-durabletask/tsp-location.yaml | 2 +- 43 files changed, 2580 insertions(+), 94 deletions(-) create mode 100644 sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_validation.py create mode 100644 sdk/durabletask/azure-mgmt-durabletask/generated_samples/retention_policies_create_or_replace_maximum_set_gen.py create mode 100644 sdk/durabletask/azure-mgmt-durabletask/generated_samples/retention_policies_delete_maximum_set_gen.py create mode 100644 sdk/durabletask/azure-mgmt-durabletask/generated_samples/retention_policies_get_maximum_set_gen.py create mode 100644 sdk/durabletask/azure-mgmt-durabletask/generated_samples/retention_policies_list_by_scheduler_maximum_set_gen.py create mode 100644 sdk/durabletask/azure-mgmt-durabletask/generated_samples/retention_policies_update_maximum_set_gen.py create mode 100644 sdk/durabletask/azure-mgmt-durabletask/generated_tests/test_durable_task_mgmt_retention_policies_operations.py create mode 100644 sdk/durabletask/azure-mgmt-durabletask/generated_tests/test_durable_task_mgmt_retention_policies_operations_async.py diff --git a/sdk/durabletask/azure-mgmt-durabletask/CHANGELOG.md b/sdk/durabletask/azure-mgmt-durabletask/CHANGELOG.md index 3fe6064f2bae..e0fc865c0564 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/CHANGELOG.md +++ b/sdk/durabletask/azure-mgmt-durabletask/CHANGELOG.md @@ -1,5 +1,28 @@ # Release History +## 1.0.0b2 (2025-04-15) + +### Features Added + + - Client `DurableTaskMgmtClient` added operation group `retention_policies` + - Added enum `PurgeableOrchestrationState` + - Added model `RetentionPolicy` + - Added model `RetentionPolicyDetails` + - Added model `RetentionPolicyProperties` + - Added model `RetentionPoliciesOperations` + - Method `RetentionPolicy.__init__` has a new overload `def __init__(self: None, properties: Optional[_models.RetentionPolicyProperties])` + - Method `RetentionPolicy.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `RetentionPolicyDetails.__init__` has a new overload `def __init__(self: None, retention_period_in_days: int, orchestration_state: Optional[Union[str, _models.PurgeableOrchestrationState]])` + - Method `RetentionPolicyDetails.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `RetentionPolicyProperties.__init__` has a new overload `def __init__(self: None, retention_policies: Optional[List[_models.RetentionPolicyDetails]])` + - Method `RetentionPolicyProperties.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `RetentionPoliciesOperations.begin_create_or_replace` has a new overload `def begin_create_or_replace(self: None, resource_group_name: str, scheduler_name: str, resource: RetentionPolicy, content_type: str)` + - Method `RetentionPoliciesOperations.begin_create_or_replace` has a new overload `def begin_create_or_replace(self: None, resource_group_name: str, scheduler_name: str, resource: JSON, content_type: str)` + - Method `RetentionPoliciesOperations.begin_create_or_replace` has a new overload `def begin_create_or_replace(self: None, resource_group_name: str, scheduler_name: str, resource: IO[bytes], content_type: str)` + - Method `RetentionPoliciesOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, scheduler_name: str, properties: RetentionPolicy, content_type: str)` + - Method `RetentionPoliciesOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, scheduler_name: str, properties: JSON, content_type: str)` + - Method `RetentionPoliciesOperations.begin_update` has a new overload `def begin_update(self: None, resource_group_name: str, scheduler_name: str, properties: IO[bytes], content_type: str)` + ## 1.0.0b1 (2025-03-25) ### Other Changes diff --git a/sdk/durabletask/azure-mgmt-durabletask/README.md b/sdk/durabletask/azure-mgmt-durabletask/README.md index 4d8546e97508..488aa4da93b3 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/README.md +++ b/sdk/durabletask/azure-mgmt-durabletask/README.md @@ -24,7 +24,7 @@ pip install azure-identity ### Authentication -By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables. +By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configuration of the following environment variables. - `AZURE_CLIENT_ID` for Azure client ID. - `AZURE_TENANT_ID` for Azure tenant ID. diff --git a/sdk/durabletask/azure-mgmt-durabletask/_meta.json b/sdk/durabletask/azure-mgmt-durabletask/_meta.json index cf7b4c41b7b0..24abd4c52459 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/_meta.json +++ b/sdk/durabletask/azure-mgmt-durabletask/_meta.json @@ -1,6 +1,6 @@ { - "commit": "7b8c7b5a83ea874d6edf8f01d44bd923a664f31e", + "commit": "9db97082212bc1bb0f428681766d69a9e8a7435d", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "typespec_src": "specification/durabletask/DurableTask.Management", - "@azure-tools/typespec-python": "0.39.1" + "@azure-tools/typespec-python": "0.42.2" } \ No newline at end of file diff --git a/sdk/durabletask/azure-mgmt-durabletask/apiview-properties.json b/sdk/durabletask/azure-mgmt-durabletask/apiview-properties.json index b6159e1610d1..5882bf05f299 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/apiview-properties.json +++ b/sdk/durabletask/azure-mgmt-durabletask/apiview-properties.json @@ -8,6 +8,9 @@ "azure.mgmt.durabletask.models.OperationDisplay": "Azure.ResourceManager.CommonTypes.OperationDisplay", "azure.mgmt.durabletask.models.Resource": "Azure.ResourceManager.CommonTypes.Resource", "azure.mgmt.durabletask.models.ProxyResource": "Azure.ResourceManager.CommonTypes.ProxyResource", + "azure.mgmt.durabletask.models.RetentionPolicy": "Microsoft.DurableTask.RetentionPolicy", + "azure.mgmt.durabletask.models.RetentionPolicyDetails": "Microsoft.DurableTask.RetentionPolicyDetails", + "azure.mgmt.durabletask.models.RetentionPolicyProperties": "Microsoft.DurableTask.RetentionPolicyProperties", "azure.mgmt.durabletask.models.TrackedResource": "Azure.ResourceManager.CommonTypes.TrackedResource", "azure.mgmt.durabletask.models.Scheduler": "Microsoft.DurableTask.Scheduler", "azure.mgmt.durabletask.models.SchedulerProperties": "Microsoft.DurableTask.SchedulerProperties", @@ -23,6 +26,7 @@ "azure.mgmt.durabletask.models.CreatedByType": "Azure.ResourceManager.CommonTypes.createdByType", "azure.mgmt.durabletask.models.ProvisioningState": "Microsoft.DurableTask.ProvisioningState", "azure.mgmt.durabletask.models.RedundancyState": "Microsoft.DurableTask.RedundancyState", + "azure.mgmt.durabletask.models.PurgeableOrchestrationState": "Microsoft.DurableTask.PurgeableOrchestrationState", "azure.mgmt.durabletask.DurableTaskMgmtClient.operations.list": "Azure.ResourceManager.Operations.list", "azure.mgmt.durabletask.DurableTaskMgmtClient.schedulers.get": "Microsoft.DurableTask.Schedulers.get", "azure.mgmt.durabletask.DurableTaskMgmtClient.schedulers.begin_create_or_update": "Microsoft.DurableTask.Schedulers.createOrUpdate", @@ -33,6 +37,11 @@ "azure.mgmt.durabletask.DurableTaskMgmtClient.task_hubs.get": "Microsoft.DurableTask.TaskHubs.get", "azure.mgmt.durabletask.DurableTaskMgmtClient.task_hubs.begin_create_or_update": "Microsoft.DurableTask.TaskHubs.createOrUpdate", "azure.mgmt.durabletask.DurableTaskMgmtClient.task_hubs.begin_delete": "Microsoft.DurableTask.TaskHubs.delete", - "azure.mgmt.durabletask.DurableTaskMgmtClient.task_hubs.list_by_scheduler": "Microsoft.DurableTask.TaskHubs.listByScheduler" + "azure.mgmt.durabletask.DurableTaskMgmtClient.task_hubs.list_by_scheduler": "Microsoft.DurableTask.TaskHubs.listByScheduler", + "azure.mgmt.durabletask.DurableTaskMgmtClient.retention_policies.get": "Microsoft.DurableTask.RetentionPolicies.get", + "azure.mgmt.durabletask.DurableTaskMgmtClient.retention_policies.begin_create_or_replace": "Microsoft.DurableTask.RetentionPolicies.createOrReplace", + "azure.mgmt.durabletask.DurableTaskMgmtClient.retention_policies.begin_update": "Microsoft.DurableTask.RetentionPolicies.update", + "azure.mgmt.durabletask.DurableTaskMgmtClient.retention_policies.begin_delete": "Microsoft.DurableTask.RetentionPolicies.delete", + "azure.mgmt.durabletask.DurableTaskMgmtClient.retention_policies.list_by_scheduler": "Microsoft.DurableTask.RetentionPolicies.listByScheduler" } } \ No newline at end of file diff --git a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_client.py b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_client.py index 0efa9fb1a17e..c28c60773bc3 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_client.py +++ b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_client.py @@ -17,7 +17,7 @@ from ._configuration import DurableTaskMgmtClientConfiguration from ._serialization import Deserializer, Serializer -from .operations import Operations, SchedulersOperations, TaskHubsOperations +from .operations import Operations, RetentionPoliciesOperations, SchedulersOperations, TaskHubsOperations if TYPE_CHECKING: from azure.core.credentials import TokenCredential @@ -32,6 +32,8 @@ class DurableTaskMgmtClient: :vartype schedulers: azure.mgmt.durabletask.operations.SchedulersOperations :ivar task_hubs: TaskHubsOperations operations :vartype task_hubs: azure.mgmt.durabletask.operations.TaskHubsOperations + :ivar retention_policies: RetentionPoliciesOperations operations + :vartype retention_policies: azure.mgmt.durabletask.operations.RetentionPoliciesOperations :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. @@ -39,7 +41,7 @@ class DurableTaskMgmtClient: :param base_url: Service host. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: The API version to use for this operation. Default value is - "2024-10-01-preview". Note that overriding this default value may result in unsupported + "2025-04-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -83,6 +85,9 @@ def __init__( self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.schedulers = SchedulersOperations(self._client, self._config, self._serialize, self._deserialize) self.task_hubs = TaskHubsOperations(self._client, self._config, self._serialize, self._deserialize) + self.retention_policies = RetentionPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_configuration.py b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_configuration.py index 2da1b849a817..5455fc9f7550 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_configuration.py +++ b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_configuration.py @@ -30,7 +30,7 @@ class DurableTaskMgmtClientConfiguration: # pylint: disable=too-many-instance-a :param base_url: Service host. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: The API version to use for this operation. Default value is - "2024-10-01-preview". Note that overriding this default value may result in unsupported + "2025-04-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ @@ -42,7 +42,7 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "2024-10-01-preview") + api_version: str = kwargs.pop("api_version", "2025-04-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_model_base.py b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_model_base.py index 3072ee252ed9..065b17f67c46 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_model_base.py +++ b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_model_base.py @@ -2,8 +2,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=protected-access, broad-except diff --git a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_patch.py b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_patch.py +++ b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_serialization.py b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_serialization.py index 7a0232de5ddc..eb86ea23c965 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_serialization.py +++ b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_serialization.py @@ -1,28 +1,10 @@ # pylint: disable=line-too-long,useless-suppression,too-many-lines +# 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. -# +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pyright: reportUnnecessaryTypeIgnoreComment=false diff --git a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_validation.py b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_validation.py new file mode 100644 index 000000000000..752b2822f9d3 --- /dev/null +++ b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_validation.py @@ -0,0 +1,50 @@ +# -------------------------------------------------------------------------- +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools + + +def api_version_validation(**kwargs): + params_added_on = kwargs.pop("params_added_on", {}) + method_added_on = kwargs.pop("method_added_on", "") + + def decorator(func): + @functools.wraps(func) + def wrapper(*args, **kwargs): + try: + # this assumes the client has an _api_version attribute + client = args[0] + client_api_version = client._config.api_version # pylint: disable=protected-access + except AttributeError: + return func(*args, **kwargs) + + if method_added_on > client_api_version: + raise ValueError( + f"'{func.__name__}' is not available in API version " + f"{client_api_version}. Pass service API version {method_added_on} or newer to your client." + ) + + unsupported = { + parameter: api_version + for api_version, parameters in params_added_on.items() + for parameter in parameters + if parameter in kwargs and api_version > client_api_version + } + if unsupported: + raise ValueError( + "".join( + [ + f"'{param}' is not available in API version {client_api_version}. " + f"Use service API version {version} or newer.\n" + for param, version in unsupported.items() + ] + ) + ) + return func(*args, **kwargs) + + return wrapper + + return decorator diff --git a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_version.py b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_version.py index be71c81bd282..bbcd28b4aa67 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_version.py +++ b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b1" +VERSION = "1.0.0b2" diff --git a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/_client.py b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/_client.py index 170298f908f3..ec192b39d5cb 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/_client.py +++ b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/_client.py @@ -17,7 +17,7 @@ from .._serialization import Deserializer, Serializer from ._configuration import DurableTaskMgmtClientConfiguration -from .operations import Operations, SchedulersOperations, TaskHubsOperations +from .operations import Operations, RetentionPoliciesOperations, SchedulersOperations, TaskHubsOperations if TYPE_CHECKING: from azure.core.credentials_async import AsyncTokenCredential @@ -32,6 +32,8 @@ class DurableTaskMgmtClient: :vartype schedulers: azure.mgmt.durabletask.aio.operations.SchedulersOperations :ivar task_hubs: TaskHubsOperations operations :vartype task_hubs: azure.mgmt.durabletask.aio.operations.TaskHubsOperations + :ivar retention_policies: RetentionPoliciesOperations operations + :vartype retention_policies: azure.mgmt.durabletask.aio.operations.RetentionPoliciesOperations :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. @@ -39,7 +41,7 @@ class DurableTaskMgmtClient: :param base_url: Service host. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: The API version to use for this operation. Default value is - "2024-10-01-preview". Note that overriding this default value may result in unsupported + "2025-04-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -83,6 +85,9 @@ def __init__( self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.schedulers = SchedulersOperations(self._client, self._config, self._serialize, self._deserialize) self.task_hubs = TaskHubsOperations(self._client, self._config, self._serialize, self._deserialize) + self.retention_policies = RetentionPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any diff --git a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/_configuration.py b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/_configuration.py index 1e9177aceb6e..34a616e21c94 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/_configuration.py +++ b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/_configuration.py @@ -30,7 +30,7 @@ class DurableTaskMgmtClientConfiguration: # pylint: disable=too-many-instance-a :param base_url: Service host. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: The API version to use for this operation. Default value is - "2024-10-01-preview". Note that overriding this default value may result in unsupported + "2025-04-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ @@ -42,7 +42,7 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "2024-10-01-preview") + api_version: str = kwargs.pop("api_version", "2025-04-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/_patch.py b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/_patch.py +++ b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/operations/__init__.py b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/operations/__init__.py index 266f9c06cc73..18dc884c6cc0 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/operations/__init__.py +++ b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/operations/__init__.py @@ -15,6 +15,7 @@ from ._operations import Operations # type: ignore from ._operations import SchedulersOperations # type: ignore from ._operations import TaskHubsOperations # type: ignore +from ._operations import RetentionPoliciesOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * @@ -24,6 +25,7 @@ "Operations", "SchedulersOperations", "TaskHubsOperations", + "RetentionPoliciesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/operations/_operations.py b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/operations/_operations.py index 06a6b4546591..089d5a842d6f 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/operations/_operations.py +++ b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/operations/_operations.py @@ -36,8 +36,14 @@ from ... import models as _models from ..._model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from ..._serialization import Deserializer, Serializer +from ..._validation import api_version_validation from ...operations._operations import ( build_operations_list_request, + build_retention_policies_create_or_replace_request, + build_retention_policies_delete_request, + build_retention_policies_get_request, + build_retention_policies_list_by_scheduler_request, + build_retention_policies_update_request, build_schedulers_create_or_update_request, build_schedulers_delete_request, build_schedulers_get_request, @@ -137,7 +143,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Operation], deserialized["value"]) + list_of_elem = _deserialize(List[_models.Operation], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -885,7 +891,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Scheduler], deserialized["value"]) + list_of_elem = _deserialize(List[_models.Scheduler], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -969,7 +975,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Scheduler], deserialized["value"]) + list_of_elem = _deserialize(List[_models.Scheduler], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -1518,7 +1524,836 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.TaskHub], deserialized["value"]) + list_of_elem = _deserialize(List[_models.TaskHub], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class RetentionPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.durabletask.aio.DurableTaskMgmtClient`'s + :attr:`retention_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: DurableTaskMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": ["api_version", "subscription_id", "resource_group_name", "scheduler_name", "accept"] + }, + ) + async def get(self, resource_group_name: str, scheduler_name: str, **kwargs: Any) -> _models.RetentionPolicy: + """Get a Retention Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scheduler_name: The name of the Scheduler. Required. + :type scheduler_name: str + :return: RetentionPolicy. The RetentionPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.durabletask.models.RetentionPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RetentionPolicy] = kwargs.pop("cls", None) + + _request = build_retention_policies_get_request( + resource_group_name=resource_group_name, + scheduler_name=scheduler_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.RetentionPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "scheduler_name", + "content_type", + "accept", + ] + }, + ) + async def _create_or_replace_initial( + self, + resource_group_name: str, + scheduler_name: str, + resource: Union[_models.RetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_retention_policies_create_or_replace_request( + resource_group_name=resource_group_name, + scheduler_name=scheduler_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_replace( + self, + resource_group_name: str, + scheduler_name: str, + resource: _models.RetentionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RetentionPolicy]: + """Create or Update a Retention Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scheduler_name: The name of the Scheduler. Required. + :type scheduler_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.durabletask.models.RetentionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns RetentionPolicy. The RetentionPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.durabletask.models.RetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_replace( + self, + resource_group_name: str, + scheduler_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RetentionPolicy]: + """Create or Update a Retention Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scheduler_name: The name of the Scheduler. Required. + :type scheduler_name: str + :param resource: Resource create parameters. Required. + :type resource: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns RetentionPolicy. The RetentionPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.durabletask.models.RetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_replace( + self, + resource_group_name: str, + scheduler_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RetentionPolicy]: + """Create or Update a Retention Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scheduler_name: The name of the Scheduler. Required. + :type scheduler_name: str + :param resource: Resource create parameters. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns RetentionPolicy. The RetentionPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.durabletask.models.RetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "scheduler_name", + "content_type", + "accept", + ] + }, + ) + async def begin_create_or_replace( + self, + resource_group_name: str, + scheduler_name: str, + resource: Union[_models.RetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.RetentionPolicy]: + """Create or Update a Retention Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scheduler_name: The name of the Scheduler. Required. + :type scheduler_name: str + :param resource: Resource create parameters. Is one of the following types: RetentionPolicy, + JSON, IO[bytes] Required. + :type resource: ~azure.mgmt.durabletask.models.RetentionPolicy or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns RetentionPolicy. The RetentionPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.durabletask.models.RetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RetentionPolicy] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_replace_initial( + resource_group_name=resource_group_name, + scheduler_name=scheduler_name, + resource=resource, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.RetentionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.RetentionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.RetentionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "scheduler_name", + "content_type", + "accept", + ] + }, + ) + async def _update_initial( + self, + resource_group_name: str, + scheduler_name: str, + properties: Union[_models.RetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_retention_policies_update_request( + resource_group_name=resource_group_name, + scheduler_name=scheduler_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + scheduler_name: str, + properties: _models.RetentionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RetentionPolicy]: + """Update a Retention Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scheduler_name: The name of the Scheduler. Required. + :type scheduler_name: str + :param properties: The resource properties to be updated. Required. + :type properties: ~azure.mgmt.durabletask.models.RetentionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns RetentionPolicy. The RetentionPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.durabletask.models.RetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + scheduler_name: str, + properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RetentionPolicy]: + """Update a Retention Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scheduler_name: The name of the Scheduler. Required. + :type scheduler_name: str + :param properties: The resource properties to be updated. Required. + :type properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns RetentionPolicy. The RetentionPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.durabletask.models.RetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + scheduler_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RetentionPolicy]: + """Update a Retention Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scheduler_name: The name of the Scheduler. Required. + :type scheduler_name: str + :param properties: The resource properties to be updated. Required. + :type properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns RetentionPolicy. The RetentionPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.durabletask.models.RetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "scheduler_name", + "content_type", + "accept", + ] + }, + ) + async def begin_update( + self, + resource_group_name: str, + scheduler_name: str, + properties: Union[_models.RetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.RetentionPolicy]: + """Update a Retention Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scheduler_name: The name of the Scheduler. Required. + :type scheduler_name: str + :param properties: The resource properties to be updated. Is one of the following types: + RetentionPolicy, JSON, IO[bytes] Required. + :type properties: ~azure.mgmt.durabletask.models.RetentionPolicy or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns RetentionPolicy. The RetentionPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.durabletask.models.RetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RetentionPolicy] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + scheduler_name=scheduler_name, + properties=properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.RetentionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.RetentionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.RetentionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": ["api_version", "subscription_id", "resource_group_name", "scheduler_name", "accept"] + }, + ) + async def _delete_initial( + self, resource_group_name: str, scheduler_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_retention_policies_delete_request( + resource_group_name=resource_group_name, + scheduler_name=scheduler_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": ["api_version", "subscription_id", "resource_group_name", "scheduler_name", "accept"] + }, + ) + async def begin_delete(self, resource_group_name: str, scheduler_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Delete a Retention Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scheduler_name: The name of the Scheduler. Required. + :type scheduler_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + scheduler_name=scheduler_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": ["api_version", "subscription_id", "resource_group_name", "scheduler_name", "accept"] + }, + ) + def list_by_scheduler( + self, resource_group_name: str, scheduler_name: str, **kwargs: Any + ) -> AsyncIterable["_models.RetentionPolicy"]: + """List Retention Policies. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scheduler_name: The name of the Scheduler. Required. + :type scheduler_name: str + :return: An iterator like instance of RetentionPolicy + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.durabletask.models.RetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RetentionPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_retention_policies_list_by_scheduler_request( + resource_group_name=resource_group_name, + scheduler_name=scheduler_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.RetentionPolicy], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) diff --git a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/operations/_patch.py b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/operations/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/operations/_patch.py +++ b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/aio/operations/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/models/__init__.py b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/models/__init__.py index 52d5443b12b9..e206fde8eabd 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/models/__init__.py +++ b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/models/__init__.py @@ -21,6 +21,9 @@ OperationDisplay, ProxyResource, Resource, + RetentionPolicy, + RetentionPolicyDetails, + RetentionPolicyProperties, Scheduler, SchedulerProperties, SchedulerPropertiesUpdate, @@ -38,6 +41,7 @@ CreatedByType, Origin, ProvisioningState, + PurgeableOrchestrationState, RedundancyState, ) from ._patch import __all__ as _patch_all @@ -52,6 +56,9 @@ "OperationDisplay", "ProxyResource", "Resource", + "RetentionPolicy", + "RetentionPolicyDetails", + "RetentionPolicyProperties", "Scheduler", "SchedulerProperties", "SchedulerPropertiesUpdate", @@ -66,6 +73,7 @@ "CreatedByType", "Origin", "ProvisioningState", + "PurgeableOrchestrationState", "RedundancyState", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore diff --git a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/models/_enums.py b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/models/_enums.py index c2f0c392d0f4..68c929623e47 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/models/_enums.py +++ b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/models/_enums.py @@ -64,6 +64,19 @@ class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The resource create request has been accepted""" +class PurgeableOrchestrationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Purgeable orchestration state to be used in retention policies.""" + + COMPLETED = "Completed" + """The orchestration is completed""" + FAILED = "Failed" + """The orchestration is failed""" + TERMINATED = "Terminated" + """The orchestration is terminated""" + CANCELED = "Canceled" + """The orchestration is terminated""" + + class RedundancyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the resource redundancy.""" diff --git a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/models/_models.py b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/models/_models.py index d00c6dae59bb..7123e870681d 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/models/_models.py +++ b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/models/_models.py @@ -225,6 +225,128 @@ class ProxyResource(Resource): """ +class RetentionPolicy(ProxyResource): + """A retention policy resource belonging to the scheduler. + + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.durabletask.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: ~azure.mgmt.durabletask.models.RetentionPolicyProperties + """ + + properties: Optional["_models.RetentionPolicyProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The resource-specific properties for this resource.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.RetentionPolicyProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RetentionPolicyDetails(_model_base.Model): + """The properties of a retention policy. + + :ivar retention_period_in_days: The retention period in days after which the orchestration will + be purged automatically. Required. + :vartype retention_period_in_days: int + :ivar orchestration_state: The orchestration state to which this policy applies. If omitted, + the policy applies to all purgeable orchestration states. Known values are: "Completed", + "Failed", "Terminated", and "Canceled". + :vartype orchestration_state: str or ~azure.mgmt.durabletask.models.PurgeableOrchestrationState + """ + + retention_period_in_days: int = rest_field( + name="retentionPeriodInDays", visibility=["read", "create", "update", "delete", "query"] + ) + """The retention period in days after which the orchestration will be purged automatically. + Required.""" + orchestration_state: Optional[Union[str, "_models.PurgeableOrchestrationState"]] = rest_field( + name="orchestrationState", visibility=["read", "create", "update", "delete", "query"] + ) + """The orchestration state to which this policy applies. If omitted, the policy applies to all + purgeable orchestration states. Known values are: \"Completed\", \"Failed\", \"Terminated\", + and \"Canceled\".""" + + @overload + def __init__( + self, + *, + retention_period_in_days: int, + orchestration_state: Optional[Union[str, "_models.PurgeableOrchestrationState"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RetentionPolicyProperties(_model_base.Model): + """The retention policy settings for the resource. + + :ivar provisioning_state: The status of the last operation. Known values are: "Succeeded", + "Failed", "Canceled", "Provisioning", "Updating", "Deleting", and "Accepted". + :vartype provisioning_state: str or ~azure.mgmt.durabletask.models.ProvisioningState + :ivar retention_policies: The orchestration retention policies. + :vartype retention_policies: list[~azure.mgmt.durabletask.models.RetentionPolicyDetails] + """ + + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """The status of the last operation. Known values are: \"Succeeded\", \"Failed\", \"Canceled\", + \"Provisioning\", \"Updating\", \"Deleting\", and \"Accepted\".""" + retention_policies: Optional[List["_models.RetentionPolicyDetails"]] = rest_field( + name="retentionPolicies", visibility=["read", "create", "update", "delete", "query"] + ) + """The orchestration retention policies.""" + + @overload + def __init__( + self, + *, + retention_policies: Optional[List["_models.RetentionPolicyDetails"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + class TrackedResource(Resource): """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. diff --git a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/models/_patch.py b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/models/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/models/_patch.py +++ b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/models/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/operations/__init__.py b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/operations/__init__.py index 266f9c06cc73..18dc884c6cc0 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/operations/__init__.py +++ b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/operations/__init__.py @@ -15,6 +15,7 @@ from ._operations import Operations # type: ignore from ._operations import SchedulersOperations # type: ignore from ._operations import TaskHubsOperations # type: ignore +from ._operations import RetentionPoliciesOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * @@ -24,6 +25,7 @@ "Operations", "SchedulersOperations", "TaskHubsOperations", + "RetentionPoliciesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/operations/_operations.py b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/operations/_operations.py index 0e01160492e4..9cff2931da29 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/operations/_operations.py +++ b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/operations/_operations.py @@ -36,6 +36,7 @@ from .._configuration import DurableTaskMgmtClientConfiguration from .._model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from .._serialization import Deserializer, Serializer +from .._validation import api_version_validation if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -53,7 +54,7 @@ def build_operations_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -74,7 +75,7 @@ def build_schedulers_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -103,7 +104,7 @@ def build_schedulers_create_or_update_request( # pylint: disable=name-too-long _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -134,7 +135,7 @@ def build_schedulers_update_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -164,7 +165,7 @@ def build_schedulers_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -192,7 +193,7 @@ def build_schedulers_list_by_resource_group_request( # pylint: disable=name-too _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -221,7 +222,7 @@ def build_schedulers_list_by_subscription_request( # pylint: disable=name-too-l _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -247,7 +248,7 @@ def build_task_hubs_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -277,7 +278,7 @@ def build_task_hubs_create_or_update_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -308,7 +309,7 @@ def build_task_hubs_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -337,7 +338,7 @@ def build_task_hubs_list_by_scheduler_request( # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -359,6 +360,152 @@ def build_task_hubs_list_by_scheduler_request( # pylint: disable=name-too-long return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) +def build_retention_policies_get_request( + resource_group_name: str, scheduler_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DurableTask/schedulers/{schedulerName}/retentionPolicies/default" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "schedulerName": _SERIALIZER.url("scheduler_name", scheduler_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_retention_policies_create_or_replace_request( # pylint: disable=name-too-long + resource_group_name: str, scheduler_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DurableTask/schedulers/{schedulerName}/retentionPolicies/default" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "schedulerName": _SERIALIZER.url("scheduler_name", scheduler_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_retention_policies_update_request( + resource_group_name: str, scheduler_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DurableTask/schedulers/{schedulerName}/retentionPolicies/default" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "schedulerName": _SERIALIZER.url("scheduler_name", scheduler_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_retention_policies_delete_request( + resource_group_name: str, scheduler_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DurableTask/schedulers/{schedulerName}/retentionPolicies/default" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "schedulerName": _SERIALIZER.url("scheduler_name", scheduler_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_retention_policies_list_by_scheduler_request( # pylint: disable=name-too-long + resource_group_name: str, scheduler_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DurableTask/schedulers/{schedulerName}/retentionPolicies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "schedulerName": _SERIALIZER.url("scheduler_name", scheduler_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + class Operations: """ .. warning:: @@ -436,7 +583,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Operation], deserialized["value"]) + list_of_elem = _deserialize(List[_models.Operation], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -1182,7 +1329,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Scheduler], deserialized["value"]) + list_of_elem = _deserialize(List[_models.Scheduler], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -1266,7 +1413,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Scheduler], deserialized["value"]) + list_of_elem = _deserialize(List[_models.Scheduler], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -1813,7 +1960,834 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.TaskHub], deserialized["value"]) + list_of_elem = _deserialize(List[_models.TaskHub], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class RetentionPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.durabletask.DurableTaskMgmtClient`'s + :attr:`retention_policies` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: DurableTaskMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": ["api_version", "subscription_id", "resource_group_name", "scheduler_name", "accept"] + }, + ) + def get(self, resource_group_name: str, scheduler_name: str, **kwargs: Any) -> _models.RetentionPolicy: + """Get a Retention Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scheduler_name: The name of the Scheduler. Required. + :type scheduler_name: str + :return: RetentionPolicy. The RetentionPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.durabletask.models.RetentionPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RetentionPolicy] = kwargs.pop("cls", None) + + _request = build_retention_policies_get_request( + resource_group_name=resource_group_name, + scheduler_name=scheduler_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.RetentionPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "scheduler_name", + "content_type", + "accept", + ] + }, + ) + def _create_or_replace_initial( + self, + resource_group_name: str, + scheduler_name: str, + resource: Union[_models.RetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_retention_policies_create_or_replace_request( + resource_group_name=resource_group_name, + scheduler_name=scheduler_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_replace( + self, + resource_group_name: str, + scheduler_name: str, + resource: _models.RetentionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RetentionPolicy]: + """Create or Update a Retention Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scheduler_name: The name of the Scheduler. Required. + :type scheduler_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.durabletask.models.RetentionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns RetentionPolicy. The RetentionPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.durabletask.models.RetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_replace( + self, + resource_group_name: str, + scheduler_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RetentionPolicy]: + """Create or Update a Retention Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scheduler_name: The name of the Scheduler. Required. + :type scheduler_name: str + :param resource: Resource create parameters. Required. + :type resource: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns RetentionPolicy. The RetentionPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.durabletask.models.RetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_replace( + self, + resource_group_name: str, + scheduler_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RetentionPolicy]: + """Create or Update a Retention Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scheduler_name: The name of the Scheduler. Required. + :type scheduler_name: str + :param resource: Resource create parameters. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns RetentionPolicy. The RetentionPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.durabletask.models.RetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "scheduler_name", + "content_type", + "accept", + ] + }, + ) + def begin_create_or_replace( + self, + resource_group_name: str, + scheduler_name: str, + resource: Union[_models.RetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.RetentionPolicy]: + """Create or Update a Retention Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scheduler_name: The name of the Scheduler. Required. + :type scheduler_name: str + :param resource: Resource create parameters. Is one of the following types: RetentionPolicy, + JSON, IO[bytes] Required. + :type resource: ~azure.mgmt.durabletask.models.RetentionPolicy or JSON or IO[bytes] + :return: An instance of LROPoller that returns RetentionPolicy. The RetentionPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.durabletask.models.RetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RetentionPolicy] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_replace_initial( + resource_group_name=resource_group_name, + scheduler_name=scheduler_name, + resource=resource, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.RetentionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.RetentionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.RetentionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "scheduler_name", + "content_type", + "accept", + ] + }, + ) + def _update_initial( + self, + resource_group_name: str, + scheduler_name: str, + properties: Union[_models.RetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_retention_policies_update_request( + resource_group_name=resource_group_name, + scheduler_name=scheduler_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + scheduler_name: str, + properties: _models.RetentionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RetentionPolicy]: + """Update a Retention Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scheduler_name: The name of the Scheduler. Required. + :type scheduler_name: str + :param properties: The resource properties to be updated. Required. + :type properties: ~azure.mgmt.durabletask.models.RetentionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns RetentionPolicy. The RetentionPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.durabletask.models.RetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + scheduler_name: str, + properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RetentionPolicy]: + """Update a Retention Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scheduler_name: The name of the Scheduler. Required. + :type scheduler_name: str + :param properties: The resource properties to be updated. Required. + :type properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns RetentionPolicy. The RetentionPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.durabletask.models.RetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + scheduler_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RetentionPolicy]: + """Update a Retention Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scheduler_name: The name of the Scheduler. Required. + :type scheduler_name: str + :param properties: The resource properties to be updated. Required. + :type properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns RetentionPolicy. The RetentionPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.durabletask.models.RetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "scheduler_name", + "content_type", + "accept", + ] + }, + ) + def begin_update( + self, + resource_group_name: str, + scheduler_name: str, + properties: Union[_models.RetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.RetentionPolicy]: + """Update a Retention Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scheduler_name: The name of the Scheduler. Required. + :type scheduler_name: str + :param properties: The resource properties to be updated. Is one of the following types: + RetentionPolicy, JSON, IO[bytes] Required. + :type properties: ~azure.mgmt.durabletask.models.RetentionPolicy or JSON or IO[bytes] + :return: An instance of LROPoller that returns RetentionPolicy. The RetentionPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.durabletask.models.RetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RetentionPolicy] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + scheduler_name=scheduler_name, + properties=properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.RetentionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.RetentionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.RetentionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": ["api_version", "subscription_id", "resource_group_name", "scheduler_name", "accept"] + }, + ) + def _delete_initial(self, resource_group_name: str, scheduler_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_retention_policies_delete_request( + resource_group_name=resource_group_name, + scheduler_name=scheduler_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": ["api_version", "subscription_id", "resource_group_name", "scheduler_name", "accept"] + }, + ) + def begin_delete(self, resource_group_name: str, scheduler_name: str, **kwargs: Any) -> LROPoller[None]: + """Delete a Retention Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scheduler_name: The name of the Scheduler. Required. + :type scheduler_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + scheduler_name=scheduler_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": ["api_version", "subscription_id", "resource_group_name", "scheduler_name", "accept"] + }, + ) + def list_by_scheduler( + self, resource_group_name: str, scheduler_name: str, **kwargs: Any + ) -> Iterable["_models.RetentionPolicy"]: + """List Retention Policies. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scheduler_name: The name of the Scheduler. Required. + :type scheduler_name: str + :return: An iterator like instance of RetentionPolicy + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.durabletask.models.RetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RetentionPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_retention_policies_list_by_scheduler_request( + resource_group_name=resource_group_name, + scheduler_name=scheduler_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.RetentionPolicy], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) diff --git a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/operations/_patch.py b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/operations/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/operations/_patch.py +++ b/sdk/durabletask/azure-mgmt-durabletask/azure/mgmt/durabletask/operations/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/operations_list.py b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/operations_list.py index fc8a2d8ee7c5..f4339feee75d 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/operations_list.py +++ b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/operations_list.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: 2024-10-01-preview/Operations_List.json +# x-ms-original-file: 2025-04-01-preview/Operations_List.json if __name__ == "__main__": main() diff --git a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/retention_policies_create_or_replace_maximum_set_gen.py b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/retention_policies_create_or_replace_maximum_set_gen.py new file mode 100644 index 000000000000..10edc7306851 --- /dev/null +++ b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/retention_policies_create_or_replace_maximum_set_gen.py @@ -0,0 +1,50 @@ +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.durabletask import DurableTaskMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-durabletask +# USAGE + python retention_policies_create_or_replace_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DurableTaskMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.retention_policies.begin_create_or_replace( + resource_group_name="rgdurabletask", + scheduler_name="testscheduler", + resource={ + "properties": { + "retentionPolicies": [ + {"retentionPeriodInDays": 30}, + {"orchestrationState": "Failed", "retentionPeriodInDays": 10}, + ] + } + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-04-01-preview/RetentionPolicies_CreateOrReplace_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/retention_policies_delete_maximum_set_gen.py b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/retention_policies_delete_maximum_set_gen.py new file mode 100644 index 000000000000..20c8bf1f2998 --- /dev/null +++ b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/retention_policies_delete_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.durabletask import DurableTaskMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-durabletask +# USAGE + python retention_policies_delete_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DurableTaskMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.retention_policies.begin_delete( + resource_group_name="rgdurabletask", + scheduler_name="testcheduler", + ).result() + + +# x-ms-original-file: 2025-04-01-preview/RetentionPolicies_Delete_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/retention_policies_get_maximum_set_gen.py b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/retention_policies_get_maximum_set_gen.py new file mode 100644 index 000000000000..a9a41db1cfbe --- /dev/null +++ b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/retention_policies_get_maximum_set_gen.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.durabletask import DurableTaskMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-durabletask +# USAGE + python retention_policies_get_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DurableTaskMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.retention_policies.get( + resource_group_name="rgdurabletask", + scheduler_name="testscheduler", + ) + print(response) + + +# x-ms-original-file: 2025-04-01-preview/RetentionPolicies_Get_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/retention_policies_list_by_scheduler_maximum_set_gen.py b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/retention_policies_list_by_scheduler_maximum_set_gen.py new file mode 100644 index 000000000000..342d222281b7 --- /dev/null +++ b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/retention_policies_list_by_scheduler_maximum_set_gen.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.durabletask import DurableTaskMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-durabletask +# USAGE + python retention_policies_list_by_scheduler_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DurableTaskMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.retention_policies.list_by_scheduler( + resource_group_name="rgdurabletask", + scheduler_name="myscheduler", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2025-04-01-preview/RetentionPolicies_ListByScheduler_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/retention_policies_update_maximum_set_gen.py b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/retention_policies_update_maximum_set_gen.py new file mode 100644 index 000000000000..9df7ebb6e01b --- /dev/null +++ b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/retention_policies_update_maximum_set_gen.py @@ -0,0 +1,51 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.durabletask import DurableTaskMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-durabletask +# USAGE + python retention_policies_update_maximum_set_gen.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DurableTaskMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.retention_policies.begin_update( + resource_group_name="rgdurabletask", + scheduler_name="testscheduler", + properties={ + "properties": { + "retentionPolicies": [ + {"retentionPeriodInDays": 30}, + {"orchestrationState": "Failed", "retentionPeriodInDays": 10}, + {"orchestrationState": "Completed", "retentionPeriodInDays": 24}, + ] + } + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-04-01-preview/RetentionPolicies_Update_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_create_or_update.py b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_create_or_update.py index 3fbfa10146a8..d285ec2b33ea 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_create_or_update.py +++ b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_create_or_update.py @@ -36,12 +36,12 @@ def main(): resource={ "location": "northcentralus", "properties": {"ipAllowlist": ["10.0.0.0/8"], "sku": {"name": "Dedicated"}}, - "tags": {"key2138": "fjaeecgnvqd", "key7131": "ryohwcoiccwsnewjigfmijz"}, + "tags": {"department": "research", "development": "true"}, }, ).result() print(response) -# x-ms-original-file: 2024-10-01-preview/Schedulers_CreateOrUpdate.json +# x-ms-original-file: 2025-04-01-preview/Schedulers_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_delete.py b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_delete.py index d581f4572a93..402f32dfc578 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_delete.py +++ b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: 2024-10-01-preview/Schedulers_Delete.json +# x-ms-original-file: 2025-04-01-preview/Schedulers_Delete.json if __name__ == "__main__": main() diff --git a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_get.py b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_get.py index 8fdca84c5c4f..2d4a134ba1f8 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_get.py +++ b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2024-10-01-preview/Schedulers_Get.json +# x-ms-original-file: 2025-04-01-preview/Schedulers_Get.json if __name__ == "__main__": main() diff --git a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_list_by_resource_group.py b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_list_by_resource_group.py index 66ba4a984a90..758da87aa4f7 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_list_by_resource_group.py +++ b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_list_by_resource_group.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: 2024-10-01-preview/Schedulers_ListByResourceGroup.json +# x-ms-original-file: 2025-04-01-preview/Schedulers_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_list_by_subscription.py b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_list_by_subscription.py index fc6aced347a8..7432253eaac6 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_list_by_subscription.py +++ b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_list_by_subscription.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: 2024-10-01-preview/Schedulers_ListBySubscription.json +# x-ms-original-file: 2025-04-01-preview/Schedulers_ListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_update.py b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_update.py index 8270e81f3a3a..7d57035d2006 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_update.py +++ b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/schedulers_update.py @@ -34,13 +34,13 @@ def main(): resource_group_name="rgopenapi", scheduler_name="testscheduler", properties={ - "properties": {"ipAllowlist": ["10.0.0.0/8"], "sku": {"capacity": 10, "name": "Dedicated"}}, - "tags": {"key8653": "lr"}, + "properties": {"ipAllowlist": ["10.0.0.0/8"], "sku": {"capacity": 3, "name": "Dedicated"}}, + "tags": {"hello": "world"}, }, ).result() print(response) -# x-ms-original-file: 2024-10-01-preview/Schedulers_Update.json +# x-ms-original-file: 2025-04-01-preview/Schedulers_Update.json if __name__ == "__main__": main() diff --git a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/task_hubs_create_or_update.py b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/task_hubs_create_or_update.py index 35a722e3dced..cc1b083d27cb 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/task_hubs_create_or_update.py +++ b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/task_hubs_create_or_update.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: 2024-10-01-preview/TaskHubs_CreateOrUpdate.json +# x-ms-original-file: 2025-04-01-preview/TaskHubs_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/task_hubs_delete.py b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/task_hubs_delete.py index 2b673b3f4c66..bb8375dad43a 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/task_hubs_delete.py +++ b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/task_hubs_delete.py @@ -33,10 +33,10 @@ def main(): client.task_hubs.begin_delete( resource_group_name="rgopenapi", scheduler_name="testscheduler", - task_hub_name="testtuskhub", + task_hub_name="testtaskhub", ).result() -# x-ms-original-file: 2024-10-01-preview/TaskHubs_Delete.json +# x-ms-original-file: 2025-04-01-preview/TaskHubs_Delete.json if __name__ == "__main__": main() diff --git a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/task_hubs_get.py b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/task_hubs_get.py index 2a7d5348c196..88d6ae9a02a1 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/task_hubs_get.py +++ b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/task_hubs_get.py @@ -33,11 +33,11 @@ def main(): response = client.task_hubs.get( resource_group_name="rgopenapi", scheduler_name="testscheduler", - task_hub_name="testtuskhub", + task_hub_name="testtaskhub", ) print(response) -# x-ms-original-file: 2024-10-01-preview/TaskHubs_Get.json +# x-ms-original-file: 2025-04-01-preview/TaskHubs_Get.json if __name__ == "__main__": main() diff --git a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/task_hubs_list_by_scheduler.py b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/task_hubs_list_by_scheduler.py index 2679fdc6daff..7b1c8143e8ed 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/generated_samples/task_hubs_list_by_scheduler.py +++ b/sdk/durabletask/azure-mgmt-durabletask/generated_samples/task_hubs_list_by_scheduler.py @@ -32,12 +32,12 @@ def main(): response = client.task_hubs.list_by_scheduler( resource_group_name="rgopenapi", - scheduler_name="testtaskhub", + scheduler_name="testscheduler", ) for item in response: print(item) -# x-ms-original-file: 2024-10-01-preview/TaskHubs_ListByScheduler.json +# x-ms-original-file: 2025-04-01-preview/TaskHubs_ListByScheduler.json if __name__ == "__main__": main() diff --git a/sdk/durabletask/azure-mgmt-durabletask/generated_tests/test_durable_task_mgmt_retention_policies_operations.py b/sdk/durabletask/azure-mgmt-durabletask/generated_tests/test_durable_task_mgmt_retention_policies_operations.py new file mode 100644 index 000000000000..96e5a528e3c8 --- /dev/null +++ b/sdk/durabletask/azure-mgmt-durabletask/generated_tests/test_durable_task_mgmt_retention_policies_operations.py @@ -0,0 +1,108 @@ +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.durabletask import DurableTaskMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDurableTaskMgmtRetentionPoliciesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DurableTaskMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_retention_policies_get(self, resource_group): + response = self.client.retention_policies.get( + resource_group_name=resource_group.name, + scheduler_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_retention_policies_begin_create_or_replace(self, resource_group): + response = self.client.retention_policies.begin_create_or_replace( + resource_group_name=resource_group.name, + scheduler_name="str", + resource={ + "id": "str", + "name": "str", + "properties": { + "provisioningState": "str", + "retentionPolicies": [{"retentionPeriodInDays": 0, "orchestrationState": "str"}], + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_retention_policies_begin_update(self, resource_group): + response = self.client.retention_policies.begin_update( + resource_group_name=resource_group.name, + scheduler_name="str", + properties={ + "id": "str", + "name": "str", + "properties": { + "provisioningState": "str", + "retentionPolicies": [{"retentionPeriodInDays": 0, "orchestrationState": "str"}], + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_retention_policies_begin_delete(self, resource_group): + response = self.client.retention_policies.begin_delete( + resource_group_name=resource_group.name, + scheduler_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_retention_policies_list_by_scheduler(self, resource_group): + response = self.client.retention_policies.list_by_scheduler( + resource_group_name=resource_group.name, + scheduler_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/durabletask/azure-mgmt-durabletask/generated_tests/test_durable_task_mgmt_retention_policies_operations_async.py b/sdk/durabletask/azure-mgmt-durabletask/generated_tests/test_durable_task_mgmt_retention_policies_operations_async.py new file mode 100644 index 000000000000..cab3b1fbf314 --- /dev/null +++ b/sdk/durabletask/azure-mgmt-durabletask/generated_tests/test_durable_task_mgmt_retention_policies_operations_async.py @@ -0,0 +1,115 @@ +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.durabletask.aio import DurableTaskMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDurableTaskMgmtRetentionPoliciesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DurableTaskMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_retention_policies_get(self, resource_group): + response = await self.client.retention_policies.get( + resource_group_name=resource_group.name, + scheduler_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_retention_policies_begin_create_or_replace(self, resource_group): + response = await ( + await self.client.retention_policies.begin_create_or_replace( + resource_group_name=resource_group.name, + scheduler_name="str", + resource={ + "id": "str", + "name": "str", + "properties": { + "provisioningState": "str", + "retentionPolicies": [{"retentionPeriodInDays": 0, "orchestrationState": "str"}], + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_retention_policies_begin_update(self, resource_group): + response = await ( + await self.client.retention_policies.begin_update( + resource_group_name=resource_group.name, + scheduler_name="str", + properties={ + "id": "str", + "name": "str", + "properties": { + "provisioningState": "str", + "retentionPolicies": [{"retentionPeriodInDays": 0, "orchestrationState": "str"}], + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_retention_policies_begin_delete(self, resource_group): + response = await ( + await self.client.retention_policies.begin_delete( + resource_group_name=resource_group.name, + scheduler_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_retention_policies_list_by_scheduler(self, resource_group): + response = self.client.retention_policies.list_by_scheduler( + resource_group_name=resource_group.name, + scheduler_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/durabletask/azure-mgmt-durabletask/tsp-location.yaml b/sdk/durabletask/azure-mgmt-durabletask/tsp-location.yaml index 741bb5714266..422b60bed9fe 100644 --- a/sdk/durabletask/azure-mgmt-durabletask/tsp-location.yaml +++ b/sdk/durabletask/azure-mgmt-durabletask/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/durabletask/DurableTask.Management -commit: 7b8c7b5a83ea874d6edf8f01d44bd923a664f31e +commit: 9db97082212bc1bb0f428681766d69a9e8a7435d repo: Azure/azure-rest-api-specs additionalDirectories: