From b44f2920cd071616be4880193628078471640f18 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 1 Nov 2024 17:32:29 +0000 Subject: [PATCH] CodeGen from PR 31246 in Azure/azure-rest-api-specs Merge 1647cec378027b81873dcd131fcb76acd85b8319 into c41ecca21c5b2667486e1e66941756ba91b2bcab --- eng/versioning/version_client.txt | 1 + pom.xml | 1 + .../CHANGELOG.md | 9 + .../README.md | 104 ++ .../SAMPLE.md | 312 ++++ .../azure-resourcemanager-durabletask/pom.xml | 75 + .../durabletask/DurableTaskManager.java | 306 ++++ .../durabletask/fluent/DurableTaskClient.java | 69 + .../durabletask/fluent/OperationsClient.java | 40 + .../durabletask/fluent/SchedulersClient.java | 267 ++++ .../durabletask/fluent/TaskHubsClient.java | 199 +++ .../fluent/models/OperationInner.java | 159 ++ .../fluent/models/SchedulerInner.java | 192 +++ .../fluent/models/TaskHubInner.java | 166 +++ .../fluent/models/package-info.java | 8 + .../durabletask/fluent/package-info.java | 8 + .../DurableTaskClientBuilder.java | 138 ++ .../implementation/DurableTaskClientImpl.java | 320 +++++ .../implementation/OperationImpl.java | 50 + .../implementation/OperationsClientImpl.java | 235 +++ .../implementation/OperationsImpl.java | 45 + .../implementation/ResourceManagerUtils.java | 195 +++ .../implementation/SchedulerImpl.java | 163 +++ .../implementation/SchedulersClientImpl.java | 1275 +++++++++++++++++ .../implementation/SchedulersImpl.java | 146 ++ .../implementation/TaskHubImpl.java | 128 ++ .../implementation/TaskHubsClientImpl.java | 918 ++++++++++++ .../implementation/TaskHubsImpl.java | 157 ++ .../models/OperationListResult.java | 113 ++ .../models/SchedulerListResult.java | 112 ++ .../models/TaskHubListResult.java | 112 ++ .../implementation/package-info.java | 8 + .../durabletask/models/ActionType.java | 46 + .../durabletask/models/Operation.java | 58 + .../durabletask/models/OperationDisplay.java | 136 ++ .../durabletask/models/Operations.java | 35 + .../durabletask/models/Origin.java | 57 + .../durabletask/models/ProvisioningState.java | 76 + .../durabletask/models/RedundancyState.java | 51 + .../durabletask/models/Scheduler.java | 265 ++++ .../models/SchedulerProperties.java | 171 +++ .../durabletask/models/SchedulerSku.java | 147 ++ .../durabletask/models/Schedulers.java | 157 ++ .../durabletask/models/TaskHub.java | 189 +++ .../durabletask/models/TaskHubProperties.java | 97 ++ .../durabletask/models/TaskHubs.java | 144 ++ .../durabletask/models/package-info.java | 8 + .../durabletask/package-info.java | 8 + .../src/main/java/module-info.java | 16 + .../proxy-config.json | 1 + .../reflect-config.json | 1 + .../generated/OperationsListSamples.java | 22 + .../SchedulersCreateOrUpdateSamples.java | 47 + .../generated/SchedulersDeleteSamples.java | 22 + .../SchedulersGetByResourceGroupSamples.java | 23 + .../SchedulersListByResourceGroupSamples.java | 22 + .../generated/SchedulersListSamples.java | 22 + .../generated/SchedulersUpdateSamples.java | 48 + .../TaskHubsCreateOrUpdateSamples.java | 28 + .../generated/TaskHubsDeleteSamples.java | 22 + .../generated/TaskHubsGetSamples.java | 23 + .../TaskHubsListBySchedulerSamples.java | 22 + .../generated/OperationDisplayTests.java | 17 + .../generated/OperationInnerTests.java | 20 + .../generated/OperationListResultTests.java | 21 + .../generated/OperationsListMockTests.java | 39 + .../generated/SchedulerInnerTests.java | 54 + .../generated/SchedulerListResultTests.java | 24 + .../generated/SchedulerPropertiesTests.java | 34 + .../generated/SchedulerSkuTests.java | 28 + .../SchedulersCreateOrUpdateMockTests.java | 65 + ...tByResourceGroupWithResponseMockTests.java | 43 + ...chedulersListByResourceGroupMockTests.java | 43 + .../generated/SchedulersListMockTests.java | 42 + .../generated/TaskHubInnerTests.java | 24 + .../generated/TaskHubListResultTests.java | 19 + .../generated/TaskHubPropertiesTests.java | 23 + .../TaskHubsCreateOrUpdateMockTests.java | 40 + .../TaskHubsGetWithResponseMockTests.java | 37 + .../TaskHubsListBySchedulerMockTests.java | 37 + .../tsp-location.yaml | 4 + sdk/durabletask/ci.yml | 46 + sdk/durabletask/pom.xml | 15 + 83 files changed, 8670 insertions(+) create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/CHANGELOG.md create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/README.md create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/SAMPLE.md create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/pom.xml create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/DurableTaskManager.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/DurableTaskClient.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/OperationsClient.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/SchedulersClient.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/TaskHubsClient.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/models/OperationInner.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/models/SchedulerInner.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/models/TaskHubInner.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/models/package-info.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/package-info.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/DurableTaskClientBuilder.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/DurableTaskClientImpl.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/OperationImpl.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/OperationsClientImpl.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/OperationsImpl.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/ResourceManagerUtils.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/SchedulerImpl.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/SchedulersClientImpl.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/SchedulersImpl.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/TaskHubImpl.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/TaskHubsClientImpl.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/TaskHubsImpl.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/models/OperationListResult.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/models/SchedulerListResult.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/models/TaskHubListResult.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/package-info.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/ActionType.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/Operation.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/OperationDisplay.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/Operations.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/Origin.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/ProvisioningState.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/RedundancyState.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/Scheduler.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/SchedulerProperties.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/SchedulerSku.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/Schedulers.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/TaskHub.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/TaskHubProperties.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/TaskHubs.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/package-info.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/package-info.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/module-info.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-durabletask/proxy-config.json create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-durabletask/reflect-config.json create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/OperationsListSamples.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersCreateOrUpdateSamples.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersDeleteSamples.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersGetByResourceGroupSamples.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersListByResourceGroupSamples.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersListSamples.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersUpdateSamples.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/TaskHubsCreateOrUpdateSamples.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/TaskHubsDeleteSamples.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/TaskHubsGetSamples.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/TaskHubsListBySchedulerSamples.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/OperationDisplayTests.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/OperationInnerTests.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/OperationListResultTests.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/OperationsListMockTests.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulerInnerTests.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulerListResultTests.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulerPropertiesTests.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulerSkuTests.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulersCreateOrUpdateMockTests.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulersGetByResourceGroupWithResponseMockTests.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulersListByResourceGroupMockTests.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulersListMockTests.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubInnerTests.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubListResultTests.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubPropertiesTests.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubsCreateOrUpdateMockTests.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubsGetWithResponseMockTests.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubsListBySchedulerMockTests.java create mode 100644 sdk/durabletask/azure-resourcemanager-durabletask/tsp-location.yaml create mode 100644 sdk/durabletask/ci.yml create mode 100644 sdk/durabletask/pom.xml diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 385352bd199d3..a5cbdcadd8c80 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -474,6 +474,7 @@ com.azure.resourcemanager:azure-resourcemanager-computeschedule;1.0.0-beta.1;1.0 com.azure.resourcemanager:azure-resourcemanager-trustedsigning;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-iotoperations;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-containerorchestratorruntime;1.0.0-beta.1;1.0.0-beta.2 +com.azure.resourcemanager:azure-resourcemanager-durabletask;1.0.0-beta.1;1.0.0-beta.1 com.azure.tools:azure-sdk-archetype;1.0.0;1.2.0-beta.1 com.azure.tools:azure-sdk-build-tool;1.0.0;1.1.0-beta.1 io.clientcore:clientcore-parent;1.0.0-beta.1;1.0.0-beta.1 diff --git a/pom.xml b/pom.xml index 866c8c788a53b..fe09f9eb97191 100644 --- a/pom.xml +++ b/pom.xml @@ -85,6 +85,7 @@ sdk/digitaltwins sdk/dnsresolver sdk/documentintelligence + sdk/durabletask sdk/dynatrace sdk/easm sdk/edgeorder diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/CHANGELOG.md b/sdk/durabletask/azure-resourcemanager-durabletask/CHANGELOG.md new file mode 100644 index 0000000000000..0eff4efb97925 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/CHANGELOG.md @@ -0,0 +1,9 @@ +# Release History + +## 1.0.0-beta.1 (2024-11-01) + +- Azure Resource Manager Durable Task client library for Java. This package contains Microsoft Azure SDK for Durable Task Management SDK. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). + +### Features Added + +- Initial release for the azure-resourcemanager-durabletask Java SDK. diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/README.md b/sdk/durabletask/azure-resourcemanager-durabletask/README.md new file mode 100644 index 0000000000000..26012d2747832 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/README.md @@ -0,0 +1,104 @@ +# Azure Resource Manager Durable Task client library for Java + +Azure Resource Manager Durable Task client library for Java. + +This package contains Microsoft Azure SDK for Durable Task Management SDK. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). + +## We'd love to hear your feedback + +We're always working on improving our products and the way we communicate with our users. So we'd love to learn what's working and how we can do better. + +If you haven't already, please take a few minutes to [complete this short survey][survey] we have put together. + +Thank you in advance for your collaboration. We really appreciate your time! + +## Documentation + +Various documentation is available to help you get started + +- [API reference documentation][docs] + +## Getting started + +### Prerequisites + +- [Java Development Kit (JDK)][jdk] with version 8 or above +- [Azure Subscription][azure_subscription] + +### Adding the package to your product + +[//]: # ({x-version-update-start;com.azure.resourcemanager:azure-resourcemanager-durabletask;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-durabletask + 1.0.0-beta.1 + +``` +[//]: # ({x-version-update-end}) + +### Include the recommended packages + +Azure Management Libraries require a `TokenCredential` implementation for authentication and an `HttpClient` implementation for HTTP client. + +[Azure Identity][azure_identity] and [Azure Core Netty HTTP][azure_core_http_netty] packages provide the default implementation. + +### Authentication + +Microsoft Entra ID token authentication relies on the [credential class][azure_identity_credentials] from [Azure Identity][azure_identity] package. + +Azure subscription ID can be configured via `AZURE_SUBSCRIPTION_ID` environment variable. + +Assuming the use of the `DefaultAzureCredential` credential class, the client can be authenticated using the following code: + +```java +AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE); +TokenCredential credential = new DefaultAzureCredentialBuilder() + .authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint()) + .build(); +DurableTaskManager manager = DurableTaskManager + .authenticate(credential, profile); +``` + +The sample code assumes global Azure. Please change `AzureEnvironment.AZURE` variable if otherwise. + +See [Authentication][authenticate] for more options. + +## Key concepts + +See [API design][design] for general introduction on design and key concepts on Azure Management Libraries. + +## Examples + +[Code snippets and samples](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/durabletask/azure-resourcemanager-durabletask/SAMPLE.md) + + +## Troubleshooting + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing guide][cg]. + +This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information see the [Code of Conduct FAQ][coc_faq] or contact with any additional questions or comments. + + +[survey]: https://microsoft.qualtrics.com/jfe/form/SV_ehN0lIk2FKEBkwd?Q_CHL=DOCS +[docs]: https://azure.github.io/azure-sdk-for-java/ +[jdk]: https://learn.microsoft.com/azure/developer/java/fundamentals/ +[azure_subscription]: https://azure.microsoft.com/free/ +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity +[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/identity/azure-identity#credentials +[azure_core_http_netty]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core-http-netty +[authenticate]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/AUTH.md +[design]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/DESIGN.md +[cg]: https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Fsdk%2Fdurabletask%2Fazure-resourcemanager-durabletask%2FREADME.png) diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/SAMPLE.md b/sdk/durabletask/azure-resourcemanager-durabletask/SAMPLE.md new file mode 100644 index 0000000000000..66f3384c696d4 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/SAMPLE.md @@ -0,0 +1,312 @@ +# Code snippets and samples + + +## Operations + +- [List](#operations_list) + +## Schedulers + +- [CreateOrUpdate](#schedulers_createorupdate) +- [Delete](#schedulers_delete) +- [GetByResourceGroup](#schedulers_getbyresourcegroup) +- [List](#schedulers_list) +- [ListByResourceGroup](#schedulers_listbyresourcegroup) +- [Update](#schedulers_update) + +## TaskHubs + +- [CreateOrUpdate](#taskhubs_createorupdate) +- [Delete](#taskhubs_delete) +- [Get](#taskhubs_get) +- [ListByScheduler](#taskhubs_listbyscheduler) +### Operations_List + +```java +/** + * Samples for Operations List. + */ +public final class OperationsListSamples { + /* + * x-ms-original-file: 2024-10-01-preview/Operations_List.json + */ + /** + * Sample code: Operations_List. + * + * @param manager Entry point to DurableTaskManager. + */ + public static void operationsList(com.azure.resourcemanager.durabletask.DurableTaskManager manager) { + manager.operations().list(com.azure.core.util.Context.NONE); + } +} +``` + +### Schedulers_CreateOrUpdate + +```java +import com.azure.resourcemanager.durabletask.models.SchedulerProperties; +import com.azure.resourcemanager.durabletask.models.SchedulerSku; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for Schedulers CreateOrUpdate. + */ +public final class SchedulersCreateOrUpdateSamples { + /* + * x-ms-original-file: 2024-10-01-preview/Schedulers_CreateOrUpdate.json + */ + /** + * Sample code: Schedulers_CreateOrUpdate. + * + * @param manager Entry point to DurableTaskManager. + */ + public static void schedulersCreateOrUpdate(com.azure.resourcemanager.durabletask.DurableTaskManager manager) { + manager.schedulers() + .define("testscheduler") + .withRegion("northcentralus") + .withExistingResourceGroup("rgopenapi") + .withTags(mapOf("key7131", "fakeTokenPlaceholder", "key2138", "fakeTokenPlaceholder")) + .withProperties(new SchedulerProperties().withIpAllowlist(Arrays.asList("10.0.0.0/8")) + .withSku(new SchedulerSku().withName("Dedicated"))) + .create(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} +``` + +### Schedulers_Delete + +```java +/** + * Samples for Schedulers Delete. + */ +public final class SchedulersDeleteSamples { + /* + * x-ms-original-file: 2024-10-01-preview/Schedulers_Delete.json + */ + /** + * Sample code: Schedulers_Delete. + * + * @param manager Entry point to DurableTaskManager. + */ + public static void schedulersDelete(com.azure.resourcemanager.durabletask.DurableTaskManager manager) { + manager.schedulers().delete("rgopenapi", "testscheduler", com.azure.core.util.Context.NONE); + } +} +``` + +### Schedulers_GetByResourceGroup + +```java +/** + * Samples for Schedulers GetByResourceGroup. + */ +public final class SchedulersGetByResourceGroupSamples { + /* + * x-ms-original-file: 2024-10-01-preview/Schedulers_Get.json + */ + /** + * Sample code: Schedulers_Get. + * + * @param manager Entry point to DurableTaskManager. + */ + public static void schedulersGet(com.azure.resourcemanager.durabletask.DurableTaskManager manager) { + manager.schedulers() + .getByResourceGroupWithResponse("rgopenapi", "testscheduler", com.azure.core.util.Context.NONE); + } +} +``` + +### Schedulers_List + +```java +/** + * Samples for Schedulers List. + */ +public final class SchedulersListSamples { + /* + * x-ms-original-file: 2024-10-01-preview/Schedulers_ListBySubscription.json + */ + /** + * Sample code: Schedulers_ListBySubscription. + * + * @param manager Entry point to DurableTaskManager. + */ + public static void schedulersListBySubscription(com.azure.resourcemanager.durabletask.DurableTaskManager manager) { + manager.schedulers().list(com.azure.core.util.Context.NONE); + } +} +``` + +### Schedulers_ListByResourceGroup + +```java +/** + * Samples for Schedulers ListByResourceGroup. + */ +public final class SchedulersListByResourceGroupSamples { + /* + * x-ms-original-file: 2024-10-01-preview/Schedulers_ListByResourceGroup.json + */ + /** + * Sample code: Schedulers_ListByResourceGroup. + * + * @param manager Entry point to DurableTaskManager. + */ + public static void schedulersListByResourceGroup(com.azure.resourcemanager.durabletask.DurableTaskManager manager) { + manager.schedulers().listByResourceGroup("rgopenapi", com.azure.core.util.Context.NONE); + } +} +``` + +### Schedulers_Update + +```java +import com.azure.resourcemanager.durabletask.models.Scheduler; +import com.azure.resourcemanager.durabletask.models.SchedulerProperties; +import com.azure.resourcemanager.durabletask.models.SchedulerSku; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for Schedulers Update. + */ +public final class SchedulersUpdateSamples { + /* + * x-ms-original-file: 2024-10-01-preview/Schedulers_Update.json + */ + /** + * Sample code: Schedulers_Update. + * + * @param manager Entry point to DurableTaskManager. + */ + public static void schedulersUpdate(com.azure.resourcemanager.durabletask.DurableTaskManager manager) { + Scheduler resource = manager.schedulers() + .getByResourceGroupWithResponse("rgopenapi", "testscheduler", com.azure.core.util.Context.NONE) + .getValue(); + resource.update() + .withTags(mapOf("key8653", "fakeTokenPlaceholder")) + .withProperties(new SchedulerProperties().withIpAllowlist(Arrays.asList("10.0.0.0/8")) + .withSku(new SchedulerSku().withName("Dedicated").withCapacity(10))) + .apply(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} +``` + +### TaskHubs_CreateOrUpdate + +```java +import com.azure.resourcemanager.durabletask.models.TaskHubProperties; + +/** + * Samples for TaskHubs CreateOrUpdate. + */ +public final class TaskHubsCreateOrUpdateSamples { + /* + * x-ms-original-file: 2024-10-01-preview/TaskHubs_CreateOrUpdate.json + */ + /** + * Sample code: TaskHubs_CreateOrUpdate. + * + * @param manager Entry point to DurableTaskManager. + */ + public static void taskHubsCreateOrUpdate(com.azure.resourcemanager.durabletask.DurableTaskManager manager) { + manager.taskHubs() + .define("testtaskhub") + .withExistingScheduler("rgopenapi", "testscheduler") + .withProperties(new TaskHubProperties()) + .create(); + } +} +``` + +### TaskHubs_Delete + +```java +/** + * Samples for TaskHubs Delete. + */ +public final class TaskHubsDeleteSamples { + /* + * x-ms-original-file: 2024-10-01-preview/TaskHubs_Delete.json + */ + /** + * Sample code: TaskHubs_Delete. + * + * @param manager Entry point to DurableTaskManager. + */ + public static void taskHubsDelete(com.azure.resourcemanager.durabletask.DurableTaskManager manager) { + manager.taskHubs().delete("rgopenapi", "testscheduler", "testtuskhub", com.azure.core.util.Context.NONE); + } +} +``` + +### TaskHubs_Get + +```java +/** + * Samples for TaskHubs Get. + */ +public final class TaskHubsGetSamples { + /* + * x-ms-original-file: 2024-10-01-preview/TaskHubs_Get.json + */ + /** + * Sample code: TaskHubs_Get. + * + * @param manager Entry point to DurableTaskManager. + */ + public static void taskHubsGet(com.azure.resourcemanager.durabletask.DurableTaskManager manager) { + manager.taskHubs() + .getWithResponse("rgopenapi", "testscheduler", "testtuskhub", com.azure.core.util.Context.NONE); + } +} +``` + +### TaskHubs_ListByScheduler + +```java +/** + * Samples for TaskHubs ListByScheduler. + */ +public final class TaskHubsListBySchedulerSamples { + /* + * x-ms-original-file: 2024-10-01-preview/TaskHubs_ListByScheduler.json + */ + /** + * Sample code: TaskHubs_ListByScheduler. + * + * @param manager Entry point to DurableTaskManager. + */ + public static void taskHubsListByScheduler(com.azure.resourcemanager.durabletask.DurableTaskManager manager) { + manager.taskHubs().listByScheduler("rgopenapi", "testtaskhub", com.azure.core.util.Context.NONE); + } +} +``` + diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/pom.xml b/sdk/durabletask/azure-resourcemanager-durabletask/pom.xml new file mode 100644 index 0000000000000..32b2390cf9876 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/pom.xml @@ -0,0 +1,75 @@ + + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure.resourcemanager + azure-resourcemanager-durabletask + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for Durable Task Management + This package contains Microsoft Azure SDK for Durable Task Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + 0 + 0 + true + false + + + + com.azure + azure-core + 1.54.0 + + + com.azure + azure-core-management + 1.15.5 + + + com.azure + azure-core-test + 1.27.0-beta.3 + test + + + com.azure + azure-identity + 1.14.0 + test + + + diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/DurableTaskManager.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/DurableTaskManager.java new file mode 100644 index 0000000000000..15bd2b71808f5 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/DurableTaskManager.java @@ -0,0 +1,306 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask; + +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.http.policy.ArmChallengeAuthenticationPolicy; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.durabletask.fluent.DurableTaskClient; +import com.azure.resourcemanager.durabletask.implementation.DurableTaskClientBuilder; +import com.azure.resourcemanager.durabletask.implementation.OperationsImpl; +import com.azure.resourcemanager.durabletask.implementation.SchedulersImpl; +import com.azure.resourcemanager.durabletask.implementation.TaskHubsImpl; +import com.azure.resourcemanager.durabletask.models.Operations; +import com.azure.resourcemanager.durabletask.models.Schedulers; +import com.azure.resourcemanager.durabletask.models.TaskHubs; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Entry point to DurableTaskManager. + */ +public final class DurableTaskManager { + private Operations operations; + + private Schedulers schedulers; + + private TaskHubs taskHubs; + + private final DurableTaskClient clientObject; + + private DurableTaskManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new DurableTaskClientBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of Durable Task service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Durable Task service API instance. + */ + public static DurableTaskManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return configure().authenticate(credential, profile); + } + + /** + * Creates an instance of Durable Task service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the Durable Task service API instance. + */ + public static DurableTaskManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new DurableTaskManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create DurableTaskManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new DurableTaskManager.Configurable(); + } + + /** + * The Configurable allowing configurations to be set. + */ + public static final class Configurable { + private static final ClientLogger LOGGER = new ClientLogger(Configurable.class); + + private HttpClient httpClient; + private HttpLogOptions httpLogOptions; + private final List policies = new ArrayList<>(); + private final List scopes = new ArrayList<>(); + private RetryPolicy retryPolicy; + private RetryOptions retryOptions; + private Duration defaultPollInterval; + + private Configurable() { + } + + /** + * Sets the http client. + * + * @param httpClient the HTTP client. + * @return the configurable object itself. + */ + public Configurable withHttpClient(HttpClient httpClient) { + this.httpClient = Objects.requireNonNull(httpClient, "'httpClient' cannot be null."); + return this; + } + + /** + * Sets the logging options to the HTTP pipeline. + * + * @param httpLogOptions the HTTP log options. + * @return the configurable object itself. + */ + public Configurable withLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = Objects.requireNonNull(httpLogOptions, "'httpLogOptions' cannot be null."); + return this; + } + + /** + * Adds the pipeline policy to the HTTP pipeline. + * + * @param policy the HTTP pipeline policy. + * @return the configurable object itself. + */ + public Configurable withPolicy(HttpPipelinePolicy policy) { + this.policies.add(Objects.requireNonNull(policy, "'policy' cannot be null.")); + return this; + } + + /** + * Adds the scope to permission sets. + * + * @param scope the scope. + * @return the configurable object itself. + */ + public Configurable withScope(String scope) { + this.scopes.add(Objects.requireNonNull(scope, "'scope' cannot be null.")); + return this; + } + + /** + * Sets the retry policy to the HTTP pipeline. + * + * @param retryPolicy the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = Objects.requireNonNull(retryPolicy, "'retryPolicy' cannot be null."); + return this; + } + + /** + * Sets the retry options for the HTTP pipeline retry policy. + *

+ * This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}. + * + * @param retryOptions the retry options for the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryOptions(RetryOptions retryOptions) { + this.retryOptions = Objects.requireNonNull(retryOptions, "'retryOptions' cannot be null."); + return this; + } + + /** + * Sets the default poll interval, used when service does not provide "Retry-After" header. + * + * @param defaultPollInterval the default poll interval. + * @return the configurable object itself. + */ + public Configurable withDefaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval + = Objects.requireNonNull(defaultPollInterval, "'defaultPollInterval' cannot be null."); + if (this.defaultPollInterval.isNegative()) { + throw LOGGER + .logExceptionAsError(new IllegalArgumentException("'defaultPollInterval' cannot be negative")); + } + return this; + } + + /** + * Creates an instance of Durable Task service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Durable Task service API instance. + */ + public DurableTaskManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + + StringBuilder userAgentBuilder = new StringBuilder(); + userAgentBuilder.append("azsdk-java") + .append("-") + .append("com.azure.resourcemanager.durabletask") + .append("/") + .append("1.0.0-beta.1"); + if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) { + userAgentBuilder.append(" (") + .append(Configuration.getGlobalConfiguration().get("java.version")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.name")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.version")) + .append("; auto-generated)"); + } else { + userAgentBuilder.append(" (auto-generated)"); + } + + if (scopes.isEmpty()) { + scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default"); + } + if (retryPolicy == null) { + if (retryOptions != null) { + retryPolicy = new RetryPolicy(retryOptions); + } else { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + } + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + policies.add(new AddHeadersFromContextPolicy()); + policies.add(new RequestIdPolicy()); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy); + policies.add(new AddDatePolicy()); + policies.add(new ArmChallengeAuthenticationPolicy(credential, scopes.toArray(new String[0]))); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(httpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); + return new DurableTaskManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** + * Gets the resource collection API of Operations. + * + * @return Resource collection API of Operations. + */ + public Operations operations() { + if (this.operations == null) { + this.operations = new OperationsImpl(clientObject.getOperations(), this); + } + return operations; + } + + /** + * Gets the resource collection API of Schedulers. It manages Scheduler. + * + * @return Resource collection API of Schedulers. + */ + public Schedulers schedulers() { + if (this.schedulers == null) { + this.schedulers = new SchedulersImpl(clientObject.getSchedulers(), this); + } + return schedulers; + } + + /** + * Gets the resource collection API of TaskHubs. It manages TaskHub. + * + * @return Resource collection API of TaskHubs. + */ + public TaskHubs taskHubs() { + if (this.taskHubs == null) { + this.taskHubs = new TaskHubsImpl(clientObject.getTaskHubs(), this); + } + return taskHubs; + } + + /** + * Gets wrapped service client DurableTaskClient providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + * + * @return Wrapped service client DurableTaskClient. + */ + public DurableTaskClient serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/DurableTaskClient.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/DurableTaskClient.java new file mode 100644 index 0000000000000..3731d0f81178e --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/DurableTaskClient.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** + * The interface for DurableTaskClient class. + */ +public interface DurableTaskClient { + /** + * Gets Service host. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + String getSubscriptionId(); + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + HttpPipeline getHttpPipeline(); + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + Duration getDefaultPollInterval(); + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + OperationsClient getOperations(); + + /** + * Gets the SchedulersClient object to access its operations. + * + * @return the SchedulersClient object. + */ + SchedulersClient getSchedulers(); + + /** + * Gets the TaskHubsClient object to access its operations. + * + * @return the TaskHubsClient object. + */ + TaskHubsClient getTaskHubs(); +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/OperationsClient.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/OperationsClient.java new file mode 100644 index 0000000000000..4b2c99323dc43 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/OperationsClient.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; +import com.azure.resourcemanager.durabletask.fluent.models.OperationInner; + +/** + * An instance of this class provides access to all the operations defined in OperationsClient. + */ +public interface OperationsClient { + /** + * List the operations for the provider. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/SchedulersClient.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/SchedulersClient.java new file mode 100644 index 0000000000000..b03765e493fdc --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/SchedulersClient.java @@ -0,0 +1,267 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.durabletask.fluent.models.SchedulerInner; + +/** + * An instance of this class provides access to all the operations defined in SchedulersClient. + */ +public interface SchedulersClient { + /** + * Get a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Scheduler along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse(String resourceGroupName, String schedulerName, + Context context); + + /** + * Get a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Scheduler. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SchedulerInner getByResourceGroup(String resourceGroupName, String schedulerName); + + /** + * Create or update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of a Durable Task Scheduler resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, SchedulerInner> beginCreateOrUpdate(String resourceGroupName, + String schedulerName, SchedulerInner resource); + + /** + * Create or update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of a Durable Task Scheduler resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, SchedulerInner> beginCreateOrUpdate(String resourceGroupName, + String schedulerName, SchedulerInner resource, Context context); + + /** + * Create or update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Durable Task Scheduler resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SchedulerInner createOrUpdate(String resourceGroupName, String schedulerName, SchedulerInner resource); + + /** + * Create or update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Durable Task Scheduler resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SchedulerInner createOrUpdate(String resourceGroupName, String schedulerName, SchedulerInner resource, + Context context); + + /** + * Update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of a Durable Task Scheduler resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, SchedulerInner> beginUpdate(String resourceGroupName, String schedulerName, + SchedulerInner properties); + + /** + * Update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of a Durable Task Scheduler resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, SchedulerInner> beginUpdate(String resourceGroupName, String schedulerName, + SchedulerInner properties, Context context); + + /** + * Update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Durable Task Scheduler resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SchedulerInner update(String resourceGroupName, String schedulerName, SchedulerInner properties); + + /** + * Update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Durable Task Scheduler resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SchedulerInner update(String resourceGroupName, String schedulerName, SchedulerInner properties, Context context); + + /** + * Delete a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String schedulerName); + + /** + * Delete a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String schedulerName, Context context); + + /** + * Delete a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String schedulerName); + + /** + * Delete a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String schedulerName, Context context); + + /** + * List Schedulers by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * List Schedulers by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * List Schedulers by subscription. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * List Schedulers by subscription. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/TaskHubsClient.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/TaskHubsClient.java new file mode 100644 index 0000000000000..5ef65e5645d06 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/TaskHubsClient.java @@ -0,0 +1,199 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.durabletask.fluent.models.TaskHubInner; + +/** + * An instance of this class provides access to all the operations defined in TaskHubsClient. + */ +public interface TaskHubsClient { + /** + * Get a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Task Hub along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String resourceGroupName, String schedulerName, String taskHubName, + Context context); + + /** + * Get a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Task Hub. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + TaskHubInner get(String resourceGroupName, String schedulerName, String taskHubName); + + /** + * Create or Update a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of a Task Hub resource belonging to the scheduler. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, TaskHubInner> beginCreateOrUpdate(String resourceGroupName, + String schedulerName, String taskHubName, TaskHubInner resource); + + /** + * Create or Update a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of a Task Hub resource belonging to the scheduler. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, TaskHubInner> beginCreateOrUpdate(String resourceGroupName, + String schedulerName, String taskHubName, TaskHubInner resource, Context context); + + /** + * Create or Update a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Task Hub resource belonging to the scheduler. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + TaskHubInner createOrUpdate(String resourceGroupName, String schedulerName, String taskHubName, + TaskHubInner resource); + + /** + * Create or Update a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Task Hub resource belonging to the scheduler. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + TaskHubInner createOrUpdate(String resourceGroupName, String schedulerName, String taskHubName, + TaskHubInner resource, Context context); + + /** + * Delete a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String schedulerName, String taskHubName); + + /** + * Delete a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String schedulerName, String taskHubName, + Context context); + + /** + * Delete a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String schedulerName, String taskHubName); + + /** + * Delete a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String schedulerName, String taskHubName, Context context); + + /** + * List Task Hubs. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TaskHub list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByScheduler(String resourceGroupName, String schedulerName); + + /** + * List Task Hubs. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TaskHub list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByScheduler(String resourceGroupName, String schedulerName, Context context); +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/models/OperationInner.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/models/OperationInner.java new file mode 100644 index 0000000000000..10e0e9ac2fc2b --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/models/OperationInner.java @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.fluent.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.durabletask.models.ActionType; +import com.azure.resourcemanager.durabletask.models.OperationDisplay; +import com.azure.resourcemanager.durabletask.models.Origin; +import java.io.IOException; + +/** + * Details of a REST API operation, returned from the Resource Provider Operations API. + */ +@Immutable +public final class OperationInner implements JsonSerializable { + /* + * The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" + */ + private String name; + + /* + * Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure + * Resource Manager/control-plane operations. + */ + private Boolean isDataAction; + + /* + * Localized display information for this particular operation. + */ + private OperationDisplay display; + + /* + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + * value is "user,system" + */ + private Origin origin; + + /* + * Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + */ + private ActionType actionType; + + /** + * Creates an instance of OperationInner class. + */ + private OperationInner() { + } + + /** + * Get the name property: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Get the isDataAction property: Whether the operation applies to data-plane. This is "true" for data-plane + * operations and "false" for Azure Resource Manager/control-plane operations. + * + * @return the isDataAction value. + */ + public Boolean isDataAction() { + return this.isDataAction; + } + + /** + * Get the display property: Localized display information for this particular operation. + * + * @return the display value. + */ + public OperationDisplay display() { + return this.display; + } + + /** + * Get the origin property: The intended executor of the operation; as in Resource Based Access Control (RBAC) and + * audit logs UX. Default value is "user,system". + * + * @return the origin value. + */ + public Origin origin() { + return this.origin; + } + + /** + * Get the actionType property: Extensible enum. Indicates the action type. "Internal" refers to actions that are + * for internal only APIs. + * + * @return the actionType value. + */ + public ActionType actionType() { + return this.actionType; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (display() != null) { + display().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("actionType", this.actionType == null ? null : this.actionType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationInner if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the OperationInner. + */ + public static OperationInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationInner deserializedOperationInner = new OperationInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedOperationInner.name = reader.getString(); + } else if ("isDataAction".equals(fieldName)) { + deserializedOperationInner.isDataAction = reader.getNullable(JsonReader::getBoolean); + } else if ("display".equals(fieldName)) { + deserializedOperationInner.display = OperationDisplay.fromJson(reader); + } else if ("origin".equals(fieldName)) { + deserializedOperationInner.origin = Origin.fromString(reader.getString()); + } else if ("actionType".equals(fieldName)) { + deserializedOperationInner.actionType = ActionType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationInner; + }); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/models/SchedulerInner.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/models/SchedulerInner.java new file mode 100644 index 0000000000000..4296cd50a3bc6 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/models/SchedulerInner.java @@ -0,0 +1,192 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.durabletask.models.SchedulerProperties; +import java.io.IOException; +import java.util.Map; + +/** + * A Durable Task Scheduler resource. + */ +@Fluent +public final class SchedulerInner extends Resource { + /* + * The resource-specific properties for this resource. + */ + private SchedulerProperties properties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of SchedulerInner class. + */ + public SchedulerInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public SchedulerProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the SchedulerInner object itself. + */ + public SchedulerInner withProperties(SchedulerProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * {@inheritDoc} + */ + @Override + public SchedulerInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public SchedulerInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (properties() != null) { + properties().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("location", location()); + jsonWriter.writeMapField("tags", tags(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SchedulerInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SchedulerInner if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SchedulerInner. + */ + public static SchedulerInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SchedulerInner deserializedSchedulerInner = new SchedulerInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedSchedulerInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedSchedulerInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedSchedulerInner.type = reader.getString(); + } else if ("location".equals(fieldName)) { + deserializedSchedulerInner.withLocation(reader.getString()); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedSchedulerInner.withTags(tags); + } else if ("properties".equals(fieldName)) { + deserializedSchedulerInner.properties = SchedulerProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedSchedulerInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedSchedulerInner; + }); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/models/TaskHubInner.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/models/TaskHubInner.java new file mode 100644 index 0000000000000..04f40d07c52ba --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/models/TaskHubInner.java @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.ProxyResource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.durabletask.models.TaskHubProperties; +import java.io.IOException; + +/** + * A Task Hub resource belonging to the scheduler. + */ +@Fluent +public final class TaskHubInner extends ProxyResource { + /* + * The resource-specific properties for this resource. + */ + private TaskHubProperties properties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of TaskHubInner class. + */ + public TaskHubInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public TaskHubProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the TaskHubInner object itself. + */ + public TaskHubInner withProperties(TaskHubProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (properties() != null) { + properties().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TaskHubInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TaskHubInner if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the TaskHubInner. + */ + public static TaskHubInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TaskHubInner deserializedTaskHubInner = new TaskHubInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedTaskHubInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedTaskHubInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedTaskHubInner.type = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedTaskHubInner.properties = TaskHubProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedTaskHubInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedTaskHubInner; + }); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/models/package-info.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/models/package-info.java new file mode 100644 index 0000000000000..0b5b6c1877195 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/models/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the inner data models for DurableTask. + */ +package com.azure.resourcemanager.durabletask.fluent.models; diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/package-info.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/package-info.java new file mode 100644 index 0000000000000..becd3bb99cabc --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/fluent/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the service clients for DurableTask. + */ +package com.azure.resourcemanager.durabletask.fluent; diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/DurableTaskClientBuilder.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/DurableTaskClientBuilder.java new file mode 100644 index 0000000000000..93fad53b04a9a --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/DurableTaskClientBuilder.java @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.implementation; + +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerAdapter; +import java.time.Duration; + +/** + * A builder for creating a new instance of the DurableTaskClientImpl type. + */ +@ServiceClientBuilder(serviceClients = { DurableTaskClientImpl.class }) +public final class DurableTaskClientBuilder { + /* + * Service host + */ + private String endpoint; + + /** + * Sets Service host. + * + * @param endpoint the endpoint value. + * @return the DurableTaskClientBuilder. + */ + public DurableTaskClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The ID of the target subscription. The value must be an UUID. + */ + private String subscriptionId; + + /** + * Sets The ID of the target subscription. The value must be an UUID. + * + * @param subscriptionId the subscriptionId value. + * @return the DurableTaskClientBuilder. + */ + public DurableTaskClientBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the DurableTaskClientBuilder. + */ + public DurableTaskClientBuilder environment(AzureEnvironment environment) { + this.environment = environment; + return this; + } + + /* + * The HTTP pipeline to send requests through + */ + private HttpPipeline pipeline; + + /** + * Sets The HTTP pipeline to send requests through. + * + * @param pipeline the pipeline value. + * @return the DurableTaskClientBuilder. + */ + public DurableTaskClientBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /* + * The default poll interval for long-running operation + */ + private Duration defaultPollInterval; + + /** + * Sets The default poll interval for long-running operation. + * + * @param defaultPollInterval the defaultPollInterval value. + * @return the DurableTaskClientBuilder. + */ + public DurableTaskClientBuilder defaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = defaultPollInterval; + return this; + } + + /* + * The serializer to serialize an object into a string + */ + private SerializerAdapter serializerAdapter; + + /** + * Sets The serializer to serialize an object into a string. + * + * @param serializerAdapter the serializerAdapter value. + * @return the DurableTaskClientBuilder. + */ + public DurableTaskClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of DurableTaskClientImpl with the provided parameters. + * + * @return an instance of DurableTaskClientImpl. + */ + public DurableTaskClientImpl buildClient() { + String localEndpoint = (endpoint != null) ? endpoint : "https://management.azure.com"; + AzureEnvironment localEnvironment = (environment != null) ? environment : AzureEnvironment.AZURE; + HttpPipeline localPipeline = (pipeline != null) + ? pipeline + : new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(); + Duration localDefaultPollInterval + = (defaultPollInterval != null) ? defaultPollInterval : Duration.ofSeconds(30); + SerializerAdapter localSerializerAdapter = (serializerAdapter != null) + ? serializerAdapter + : SerializerFactory.createDefaultManagementSerializerAdapter(); + DurableTaskClientImpl client = new DurableTaskClientImpl(localPipeline, localSerializerAdapter, + localDefaultPollInterval, localEnvironment, localEndpoint, this.subscriptionId); + return client; + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/DurableTaskClientImpl.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/DurableTaskClientImpl.java new file mode 100644 index 0000000000000..e940b9a4de74c --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/DurableTaskClientImpl.java @@ -0,0 +1,320 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.implementation; + +import com.azure.core.annotation.ServiceClient; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpResponse; +import com.azure.core.http.rest.Response; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.exception.ManagementError; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.management.polling.PollerFactory; +import com.azure.core.util.Context; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.durabletask.fluent.DurableTaskClient; +import com.azure.resourcemanager.durabletask.fluent.OperationsClient; +import com.azure.resourcemanager.durabletask.fluent.SchedulersClient; +import com.azure.resourcemanager.durabletask.fluent.TaskHubsClient; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the DurableTaskClientImpl type. + */ +@ServiceClient(builder = DurableTaskClientBuilder.class) +public final class DurableTaskClientImpl implements DurableTaskClient { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Version parameter. + */ + private final String apiVersion; + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + public String getApiVersion() { + return this.apiVersion; + } + + /** + * The ID of the target subscription. The value must be an UUID. + */ + private final String subscriptionId; + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * The default poll interval for long-running operation. + */ + private final Duration defaultPollInterval; + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + public Duration getDefaultPollInterval() { + return this.defaultPollInterval; + } + + /** + * The OperationsClient object to access its operations. + */ + private final OperationsClient operations; + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + public OperationsClient getOperations() { + return this.operations; + } + + /** + * The SchedulersClient object to access its operations. + */ + private final SchedulersClient schedulers; + + /** + * Gets the SchedulersClient object to access its operations. + * + * @return the SchedulersClient object. + */ + public SchedulersClient getSchedulers() { + return this.schedulers; + } + + /** + * The TaskHubsClient object to access its operations. + */ + private final TaskHubsClient taskHubs; + + /** + * Gets the TaskHubsClient object to access its operations. + * + * @return the TaskHubsClient object. + */ + public TaskHubsClient getTaskHubs() { + return this.taskHubs; + } + + /** + * Initializes an instance of DurableTaskClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param defaultPollInterval The default poll interval for long-running operation. + * @param environment The Azure environment. + * @param endpoint Service host. + * @param subscriptionId The ID of the target subscription. The value must be an UUID. + */ + DurableTaskClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, Duration defaultPollInterval, + AzureEnvironment environment, String endpoint, String subscriptionId) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.endpoint = endpoint; + this.subscriptionId = subscriptionId; + this.apiVersion = "2024-10-01-preview"; + this.operations = new OperationsClientImpl(this); + this.schedulers = new SchedulersClientImpl(this); + this.taskHubs = new TaskHubsClientImpl(this); + } + + /** + * Gets default client context. + * + * @return the default client context. + */ + public Context getContext() { + return Context.NONE; + } + + /** + * Merges default client context with provided context. + * + * @param context the context to be merged with default client context. + * @return the merged context. + */ + public Context mergeContext(Context context) { + return CoreUtils.mergeContexts(this.getContext(), context); + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param httpPipeline the http pipeline. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return poller flux for poll result and final result. + */ + public PollerFlux, U> getLroResult(Mono>> activationResponse, + HttpPipeline httpPipeline, Type pollResultType, Type finalResultType, Context context) { + return PollerFactory.create(serializerAdapter, httpPipeline, pollResultType, finalResultType, + defaultPollInterval, activationResponse, context); + } + + /** + * Gets the final result, or an error, based on last async poll response. + * + * @param response the last async poll response. + * @param type of poll result. + * @param type of final result. + * @return the final result, or an error. + */ + public Mono getLroFinalResultOrError(AsyncPollResponse, U> response) { + if (response.getStatus() != LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) { + String errorMessage; + ManagementError managementError = null; + HttpResponse errorResponse = null; + PollResult.Error lroError = response.getValue().getError(); + if (lroError != null) { + errorResponse = new HttpResponseImpl(lroError.getResponseStatusCode(), lroError.getResponseHeaders(), + lroError.getResponseBody()); + + errorMessage = response.getValue().getError().getMessage(); + String errorBody = response.getValue().getError().getResponseBody(); + if (errorBody != null) { + // try to deserialize error body to ManagementError + try { + managementError = this.getSerializerAdapter() + .deserialize(errorBody, ManagementError.class, SerializerEncoding.JSON); + if (managementError.getCode() == null || managementError.getMessage() == null) { + managementError = null; + } + } catch (IOException | RuntimeException ioe) { + LOGGER.logThrowableAsWarning(ioe); + } + } + } else { + // fallback to default error message + errorMessage = "Long running operation failed."; + } + if (managementError == null) { + // fallback to default ManagementError + managementError = new ManagementError(response.getStatus().toString(), errorMessage); + } + return Mono.error(new ManagementException(errorMessage, errorResponse, managementError)); + } else { + return response.getFinalResult(); + } + } + + private static final class HttpResponseImpl extends HttpResponse { + private final int statusCode; + + private final byte[] responseBody; + + private final HttpHeaders httpHeaders; + + HttpResponseImpl(int statusCode, HttpHeaders httpHeaders, String responseBody) { + super(null); + this.statusCode = statusCode; + this.httpHeaders = httpHeaders; + this.responseBody = responseBody == null ? null : responseBody.getBytes(StandardCharsets.UTF_8); + } + + public int getStatusCode() { + return statusCode; + } + + public String getHeaderValue(String s) { + return httpHeaders.getValue(HttpHeaderName.fromString(s)); + } + + public HttpHeaders getHeaders() { + return httpHeaders; + } + + public Flux getBody() { + return Flux.just(ByteBuffer.wrap(responseBody)); + } + + public Mono getBodyAsByteArray() { + return Mono.just(responseBody); + } + + public Mono getBodyAsString() { + return Mono.just(new String(responseBody, StandardCharsets.UTF_8)); + } + + public Mono getBodyAsString(Charset charset) { + return Mono.just(new String(responseBody, charset)); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(DurableTaskClientImpl.class); +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/OperationImpl.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/OperationImpl.java new file mode 100644 index 0000000000000..f8a7088a170ce --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/OperationImpl.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.implementation; + +import com.azure.resourcemanager.durabletask.fluent.models.OperationInner; +import com.azure.resourcemanager.durabletask.models.ActionType; +import com.azure.resourcemanager.durabletask.models.Operation; +import com.azure.resourcemanager.durabletask.models.OperationDisplay; +import com.azure.resourcemanager.durabletask.models.Origin; + +public final class OperationImpl implements Operation { + private OperationInner innerObject; + + private final com.azure.resourcemanager.durabletask.DurableTaskManager serviceManager; + + OperationImpl(OperationInner innerObject, com.azure.resourcemanager.durabletask.DurableTaskManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String name() { + return this.innerModel().name(); + } + + public Boolean isDataAction() { + return this.innerModel().isDataAction(); + } + + public OperationDisplay display() { + return this.innerModel().display(); + } + + public Origin origin() { + return this.innerModel().origin(); + } + + public ActionType actionType() { + return this.innerModel().actionType(); + } + + public OperationInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.durabletask.DurableTaskManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/OperationsClientImpl.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/OperationsClientImpl.java new file mode 100644 index 0000000000000..763a2fd5a7464 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/OperationsClientImpl.java @@ -0,0 +1,235 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.resourcemanager.durabletask.fluent.OperationsClient; +import com.azure.resourcemanager.durabletask.fluent.models.OperationInner; +import com.azure.resourcemanager.durabletask.implementation.models.OperationListResult; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in OperationsClient. + */ +public final class OperationsClientImpl implements OperationsClient { + /** + * The proxy service used to perform REST calls. + */ + private final OperationsService service; + + /** + * The service client containing this operation class. + */ + private final DurableTaskClientImpl client; + + /** + * Initializes an instance of OperationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationsClientImpl(DurableTaskClientImpl client) { + this.service + = RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DurableTaskClientOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "DurableTaskClientOpe") + public interface OperationsService { + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.DurableTask/operations") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, Context context); + } + + /** + * List the operations for the provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync() { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List the operations for the provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>(() -> listSinglePageAsync(context), + nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * List the operations for the provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.listNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/OperationsImpl.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/OperationsImpl.java new file mode 100644 index 0000000000000..b045326bd5820 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/OperationsImpl.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.durabletask.fluent.OperationsClient; +import com.azure.resourcemanager.durabletask.fluent.models.OperationInner; +import com.azure.resourcemanager.durabletask.models.Operation; +import com.azure.resourcemanager.durabletask.models.Operations; + +public final class OperationsImpl implements Operations { + private static final ClientLogger LOGGER = new ClientLogger(OperationsImpl.class); + + private final OperationsClient innerClient; + + private final com.azure.resourcemanager.durabletask.DurableTaskManager serviceManager; + + public OperationsImpl(OperationsClient innerClient, + com.azure.resourcemanager.durabletask.DurableTaskManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return ResourceManagerUtils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + private OperationsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.durabletask.DurableTaskManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/ResourceManagerUtils.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/ResourceManagerUtils.java new file mode 100644 index 0000000000000..6605cb53e00ff --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/ResourceManagerUtils.java @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.implementation; + +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.util.CoreUtils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import reactor.core.publisher.Flux; + +final class ResourceManagerUtils { + private ResourceManagerUtils() { + } + + static String getValueFromIdByName(String id, String name) { + if (id == null) { + return null; + } + Iterator itr = Arrays.stream(id.split("/")).iterator(); + while (itr.hasNext()) { + String part = itr.next(); + if (part != null && !part.trim().isEmpty()) { + if (part.equalsIgnoreCase(name)) { + if (itr.hasNext()) { + return itr.next(); + } else { + return null; + } + } + } + } + return null; + } + + static String getValueFromIdByParameterName(String id, String pathTemplate, String parameterName) { + if (id == null || pathTemplate == null) { + return null; + } + String parameterNameParentheses = "{" + parameterName + "}"; + List idSegmentsReverted = Arrays.asList(id.split("/")); + List pathSegments = Arrays.asList(pathTemplate.split("/")); + Collections.reverse(idSegmentsReverted); + Iterator idItrReverted = idSegmentsReverted.iterator(); + int pathIndex = pathSegments.size(); + while (idItrReverted.hasNext() && pathIndex > 0) { + String idSegment = idItrReverted.next(); + String pathSegment = pathSegments.get(--pathIndex); + if (!CoreUtils.isNullOrEmpty(idSegment) && !CoreUtils.isNullOrEmpty(pathSegment)) { + if (pathSegment.equalsIgnoreCase(parameterNameParentheses)) { + if (pathIndex == 0 || (pathIndex == 1 && pathSegments.get(0).isEmpty())) { + List segments = new ArrayList<>(); + segments.add(idSegment); + idItrReverted.forEachRemaining(segments::add); + Collections.reverse(segments); + if (!segments.isEmpty() && segments.get(0).isEmpty()) { + segments.remove(0); + } + return String.join("/", segments); + } else { + return idSegment; + } + } + } + } + return null; + } + + static PagedIterable mapPage(PagedIterable pageIterable, Function mapper) { + return new PagedIterableImpl<>(pageIterable, mapper); + } + + private static final class PagedIterableImpl extends PagedIterable { + + private final PagedIterable pagedIterable; + private final Function mapper; + private final Function, PagedResponse> pageMapper; + + private PagedIterableImpl(PagedIterable pagedIterable, Function mapper) { + super(PagedFlux.create(() -> (continuationToken, pageSize) -> Flux + .fromStream(pagedIterable.streamByPage().map(getPageMapper(mapper))))); + this.pagedIterable = pagedIterable; + this.mapper = mapper; + this.pageMapper = getPageMapper(mapper); + } + + private static Function, PagedResponse> getPageMapper(Function mapper) { + return page -> new PagedResponseBase(page.getRequest(), page.getStatusCode(), page.getHeaders(), + page.getElements().stream().map(mapper).collect(Collectors.toList()), page.getContinuationToken(), + null); + } + + @Override + public Stream stream() { + return pagedIterable.stream().map(mapper); + } + + @Override + public Stream> streamByPage() { + return pagedIterable.streamByPage().map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken) { + return pagedIterable.streamByPage(continuationToken).map(pageMapper); + } + + @Override + public Stream> streamByPage(int preferredPageSize) { + return pagedIterable.streamByPage(preferredPageSize).map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken, int preferredPageSize) { + return pagedIterable.streamByPage(continuationToken, preferredPageSize).map(pageMapper); + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(pagedIterable.iterator(), mapper); + } + + @Override + public Iterable> iterableByPage() { + return new IterableImpl<>(pagedIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken, preferredPageSize), pageMapper); + } + } + + private static final class IteratorImpl implements Iterator { + + private final Iterator iterator; + private final Function mapper; + + private IteratorImpl(Iterator iterator, Function mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public S next() { + return mapper.apply(iterator.next()); + } + + @Override + public void remove() { + iterator.remove(); + } + } + + private static final class IterableImpl implements Iterable { + + private final Iterable iterable; + private final Function mapper; + + private IterableImpl(Iterable iterable, Function mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(iterable.iterator(), mapper); + } + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/SchedulerImpl.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/SchedulerImpl.java new file mode 100644 index 0000000000000..f1466d6d27f50 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/SchedulerImpl.java @@ -0,0 +1,163 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.implementation; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.durabletask.fluent.models.SchedulerInner; +import com.azure.resourcemanager.durabletask.models.Scheduler; +import com.azure.resourcemanager.durabletask.models.SchedulerProperties; +import java.util.Collections; +import java.util.Map; + +public final class SchedulerImpl implements Scheduler, Scheduler.Definition, Scheduler.Update { + private SchedulerInner innerObject; + + private final com.azure.resourcemanager.durabletask.DurableTaskManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public String location() { + return this.innerModel().location(); + } + + public Map tags() { + Map inner = this.innerModel().tags(); + if (inner != null) { + return Collections.unmodifiableMap(inner); + } else { + return Collections.emptyMap(); + } + } + + public SchedulerProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public SchedulerInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.durabletask.DurableTaskManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String schedulerName; + + public SchedulerImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public Scheduler create() { + this.innerObject = serviceManager.serviceClient() + .getSchedulers() + .createOrUpdate(resourceGroupName, schedulerName, this.innerModel(), Context.NONE); + return this; + } + + public Scheduler create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getSchedulers() + .createOrUpdate(resourceGroupName, schedulerName, this.innerModel(), context); + return this; + } + + SchedulerImpl(String name, com.azure.resourcemanager.durabletask.DurableTaskManager serviceManager) { + this.innerObject = new SchedulerInner(); + this.serviceManager = serviceManager; + this.schedulerName = name; + } + + public SchedulerImpl update() { + return this; + } + + public Scheduler apply() { + this.innerObject = serviceManager.serviceClient() + .getSchedulers() + .update(resourceGroupName, schedulerName, this.innerModel(), Context.NONE); + return this; + } + + public Scheduler apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getSchedulers() + .update(resourceGroupName, schedulerName, this.innerModel(), context); + return this; + } + + SchedulerImpl(SchedulerInner innerObject, com.azure.resourcemanager.durabletask.DurableTaskManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.schedulerName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "schedulers"); + } + + public Scheduler refresh() { + this.innerObject = serviceManager.serviceClient() + .getSchedulers() + .getByResourceGroupWithResponse(resourceGroupName, schedulerName, Context.NONE) + .getValue(); + return this; + } + + public Scheduler refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getSchedulers() + .getByResourceGroupWithResponse(resourceGroupName, schedulerName, context) + .getValue(); + return this; + } + + public SchedulerImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public SchedulerImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public SchedulerImpl withTags(Map tags) { + this.innerModel().withTags(tags); + return this; + } + + public SchedulerImpl withProperties(SchedulerProperties properties) { + this.innerModel().withProperties(properties); + return this; + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/SchedulersClientImpl.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/SchedulersClientImpl.java new file mode 100644 index 0000000000000..653dd1a64d017 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/SchedulersClientImpl.java @@ -0,0 +1,1275 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.durabletask.fluent.SchedulersClient; +import com.azure.resourcemanager.durabletask.fluent.models.SchedulerInner; +import com.azure.resourcemanager.durabletask.implementation.models.SchedulerListResult; +import java.nio.ByteBuffer; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in SchedulersClient. + */ +public final class SchedulersClientImpl implements SchedulersClient { + /** + * The proxy service used to perform REST calls. + */ + private final SchedulersService service; + + /** + * The service client containing this operation class. + */ + private final DurableTaskClientImpl client; + + /** + * Initializes an instance of SchedulersClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SchedulersClientImpl(DurableTaskClientImpl client) { + this.service + = RestProxy.create(SchedulersService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DurableTaskClientSchedulers to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "DurableTaskClientSch") + public interface SchedulersService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DurableTask/schedulers/{schedulerName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("schedulerName") String schedulerName, + @HeaderParam("Accept") String accept, Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DurableTask/schedulers/{schedulerName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("schedulerName") String schedulerName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") SchedulerInner resource, Context context); + + @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DurableTask/schedulers/{schedulerName}") + @ExpectedResponses({ 200, 202 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> update(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("schedulerName") String schedulerName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") SchedulerInner properties, Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DurableTask/schedulers/{schedulerName}") + @ExpectedResponses({ 202, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("schedulerName") String schedulerName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DurableTask/schedulers") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroup(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.DurableTask/schedulers") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroupNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listBySubscriptionNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * Get a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Scheduler along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, + String schedulerName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (schedulerName == null) { + return Mono.error(new IllegalArgumentException("Parameter schedulerName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, schedulerName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Scheduler along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, + String schedulerName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (schedulerName == null) { + return Mono.error(new IllegalArgumentException("Parameter schedulerName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.getByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, schedulerName, accept, context); + } + + /** + * Get a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Scheduler on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, String schedulerName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, schedulerName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Scheduler along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse(String resourceGroupName, String schedulerName, + Context context) { + return getByResourceGroupWithResponseAsync(resourceGroupName, schedulerName, context).block(); + } + + /** + * Get a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Scheduler. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SchedulerInner getByResourceGroup(String resourceGroupName, String schedulerName) { + return getByResourceGroupWithResponse(resourceGroupName, schedulerName, Context.NONE).getValue(); + } + + /** + * Create or update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Durable Task Scheduler resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, + String schedulerName, SchedulerInner resource) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (schedulerName == null) { + return Mono.error(new IllegalArgumentException("Parameter schedulerName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, schedulerName, contentType, accept, resource, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create or update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Durable Task Scheduler resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, + String schedulerName, SchedulerInner resource, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (schedulerName == null) { + return Mono.error(new IllegalArgumentException("Parameter schedulerName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, schedulerName, contentType, accept, resource, context); + } + + /** + * Create or update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of a Durable Task Scheduler resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, SchedulerInner> beginCreateOrUpdateAsync(String resourceGroupName, + String schedulerName, SchedulerInner resource) { + Mono>> mono + = createOrUpdateWithResponseAsync(resourceGroupName, schedulerName, resource); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + SchedulerInner.class, SchedulerInner.class, this.client.getContext()); + } + + /** + * Create or update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of a Durable Task Scheduler resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, SchedulerInner> beginCreateOrUpdateAsync(String resourceGroupName, + String schedulerName, SchedulerInner resource, Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = createOrUpdateWithResponseAsync(resourceGroupName, schedulerName, resource, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + SchedulerInner.class, SchedulerInner.class, context); + } + + /** + * Create or update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of a Durable Task Scheduler resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, SchedulerInner> beginCreateOrUpdate(String resourceGroupName, + String schedulerName, SchedulerInner resource) { + return this.beginCreateOrUpdateAsync(resourceGroupName, schedulerName, resource).getSyncPoller(); + } + + /** + * Create or update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of a Durable Task Scheduler resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, SchedulerInner> beginCreateOrUpdate(String resourceGroupName, + String schedulerName, SchedulerInner resource, Context context) { + return this.beginCreateOrUpdateAsync(resourceGroupName, schedulerName, resource, context).getSyncPoller(); + } + + /** + * Create or update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Durable Task Scheduler resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String schedulerName, + SchedulerInner resource) { + return beginCreateOrUpdateAsync(resourceGroupName, schedulerName, resource).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create or update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Durable Task Scheduler resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String schedulerName, + SchedulerInner resource, Context context) { + return beginCreateOrUpdateAsync(resourceGroupName, schedulerName, resource, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create or update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Durable Task Scheduler resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SchedulerInner createOrUpdate(String resourceGroupName, String schedulerName, SchedulerInner resource) { + return createOrUpdateAsync(resourceGroupName, schedulerName, resource).block(); + } + + /** + * Create or update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Durable Task Scheduler resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SchedulerInner createOrUpdate(String resourceGroupName, String schedulerName, SchedulerInner resource, + Context context) { + return createOrUpdateAsync(resourceGroupName, schedulerName, resource, context).block(); + } + + /** + * Update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Durable Task Scheduler resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> updateWithResponseAsync(String resourceGroupName, String schedulerName, + SchedulerInner properties) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (schedulerName == null) { + return Mono.error(new IllegalArgumentException("Parameter schedulerName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.update(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, schedulerName, contentType, accept, properties, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Durable Task Scheduler resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> updateWithResponseAsync(String resourceGroupName, String schedulerName, + SchedulerInner properties, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (schedulerName == null) { + return Mono.error(new IllegalArgumentException("Parameter schedulerName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.update(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, schedulerName, contentType, accept, properties, context); + } + + /** + * Update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of a Durable Task Scheduler resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, SchedulerInner> beginUpdateAsync(String resourceGroupName, + String schedulerName, SchedulerInner properties) { + Mono>> mono = updateWithResponseAsync(resourceGroupName, schedulerName, properties); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + SchedulerInner.class, SchedulerInner.class, this.client.getContext()); + } + + /** + * Update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of a Durable Task Scheduler resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, SchedulerInner> beginUpdateAsync(String resourceGroupName, + String schedulerName, SchedulerInner properties, Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = updateWithResponseAsync(resourceGroupName, schedulerName, properties, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + SchedulerInner.class, SchedulerInner.class, context); + } + + /** + * Update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of a Durable Task Scheduler resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, SchedulerInner> beginUpdate(String resourceGroupName, + String schedulerName, SchedulerInner properties) { + return this.beginUpdateAsync(resourceGroupName, schedulerName, properties).getSyncPoller(); + } + + /** + * Update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of a Durable Task Scheduler resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, SchedulerInner> beginUpdate(String resourceGroupName, + String schedulerName, SchedulerInner properties, Context context) { + return this.beginUpdateAsync(resourceGroupName, schedulerName, properties, context).getSyncPoller(); + } + + /** + * Update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Durable Task Scheduler resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync(String resourceGroupName, String schedulerName, + SchedulerInner properties) { + return beginUpdateAsync(resourceGroupName, schedulerName, properties).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Durable Task Scheduler resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync(String resourceGroupName, String schedulerName, SchedulerInner properties, + Context context) { + return beginUpdateAsync(resourceGroupName, schedulerName, properties, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Durable Task Scheduler resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SchedulerInner update(String resourceGroupName, String schedulerName, SchedulerInner properties) { + return updateAsync(resourceGroupName, schedulerName, properties).block(); + } + + /** + * Update a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Durable Task Scheduler resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SchedulerInner update(String resourceGroupName, String schedulerName, SchedulerInner properties, + Context context) { + return updateAsync(resourceGroupName, schedulerName, properties, context).block(); + } + + /** + * Delete a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> deleteWithResponseAsync(String resourceGroupName, String schedulerName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (schedulerName == null) { + return Mono.error(new IllegalArgumentException("Parameter schedulerName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, schedulerName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> deleteWithResponseAsync(String resourceGroupName, String schedulerName, + Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (schedulerName == null) { + return Mono.error(new IllegalArgumentException("Parameter schedulerName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.delete(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, schedulerName, accept, context); + } + + /** + * Delete a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, String schedulerName) { + Mono>> mono = deleteWithResponseAsync(resourceGroupName, schedulerName); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + this.client.getContext()); + } + + /** + * Delete a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, String schedulerName, + Context context) { + context = this.client.mergeContext(context); + Mono>> mono = deleteWithResponseAsync(resourceGroupName, schedulerName, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + context); + } + + /** + * Delete a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, String schedulerName) { + return this.beginDeleteAsync(resourceGroupName, schedulerName).getSyncPoller(); + } + + /** + * Delete a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, String schedulerName, + Context context) { + return this.beginDeleteAsync(resourceGroupName, schedulerName, context).getSyncPoller(); + } + + /** + * Delete a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String schedulerName) { + return beginDeleteAsync(resourceGroupName, schedulerName).last().flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String schedulerName, Context context) { + return beginDeleteAsync(resourceGroupName, schedulerName, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String schedulerName) { + deleteAsync(resourceGroupName, schedulerName).block(); + } + + /** + * Delete a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String schedulerName, Context context) { + deleteAsync(resourceGroupName, schedulerName, context).block(); + } + + /** + * List Schedulers by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupSinglePageAsync(String resourceGroupName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List Schedulers by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupSinglePageAsync(String resourceGroupName, + Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List Schedulers by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName) { + return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroupName), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink)); + } + + /** + * List Schedulers by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName, Context context) { + return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroupName, context), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink, context)); + } + + /** + * List Schedulers by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName)); + } + + /** + * List Schedulers by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context)); + } + + /** + * List Schedulers by subscription. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync() { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List Schedulers by subscription. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .list(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), accept, + context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List Schedulers by subscription. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), + nextLink -> listBySubscriptionNextSinglePageAsync(nextLink)); + } + + /** + * List Schedulers by subscription. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>(() -> listSinglePageAsync(context), + nextLink -> listBySubscriptionNextSinglePageAsync(nextLink, context)); + } + + /** + * List Schedulers by subscription. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * List Schedulers by subscription. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listByResourceGroupNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupNextSinglePageAsync(String nextLink, + Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listByResourceGroupNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionNextSinglePageAsync(String nextLink, + Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/SchedulersImpl.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/SchedulersImpl.java new file mode 100644 index 0000000000000..e6558275cea9e --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/SchedulersImpl.java @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.durabletask.fluent.SchedulersClient; +import com.azure.resourcemanager.durabletask.fluent.models.SchedulerInner; +import com.azure.resourcemanager.durabletask.models.Scheduler; +import com.azure.resourcemanager.durabletask.models.Schedulers; + +public final class SchedulersImpl implements Schedulers { + private static final ClientLogger LOGGER = new ClientLogger(SchedulersImpl.class); + + private final SchedulersClient innerClient; + + private final com.azure.resourcemanager.durabletask.DurableTaskManager serviceManager; + + public SchedulersImpl(SchedulersClient innerClient, + com.azure.resourcemanager.durabletask.DurableTaskManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getByResourceGroupWithResponse(String resourceGroupName, String schedulerName, + Context context) { + Response inner + = this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, schedulerName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new SchedulerImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public Scheduler getByResourceGroup(String resourceGroupName, String schedulerName) { + SchedulerInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, schedulerName); + if (inner != null) { + return new SchedulerImpl(inner, this.manager()); + } else { + return null; + } + } + + public void deleteByResourceGroup(String resourceGroupName, String schedulerName) { + this.serviceClient().delete(resourceGroupName, schedulerName); + } + + public void delete(String resourceGroupName, String schedulerName, Context context) { + this.serviceClient().delete(resourceGroupName, schedulerName, context); + } + + public PagedIterable listByResourceGroup(String resourceGroupName) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName); + return ResourceManagerUtils.mapPage(inner, inner1 -> new SchedulerImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new SchedulerImpl(inner1, this.manager())); + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return ResourceManagerUtils.mapPage(inner, inner1 -> new SchedulerImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new SchedulerImpl(inner1, this.manager())); + } + + public Scheduler getById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String schedulerName = ResourceManagerUtils.getValueFromIdByName(id, "schedulers"); + if (schedulerName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'schedulers'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, schedulerName, Context.NONE).getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String schedulerName = ResourceManagerUtils.getValueFromIdByName(id, "schedulers"); + if (schedulerName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'schedulers'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, schedulerName, context); + } + + public void deleteById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String schedulerName = ResourceManagerUtils.getValueFromIdByName(id, "schedulers"); + if (schedulerName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'schedulers'.", id))); + } + this.delete(resourceGroupName, schedulerName, Context.NONE); + } + + public void deleteByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String schedulerName = ResourceManagerUtils.getValueFromIdByName(id, "schedulers"); + if (schedulerName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'schedulers'.", id))); + } + this.delete(resourceGroupName, schedulerName, context); + } + + private SchedulersClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.durabletask.DurableTaskManager manager() { + return this.serviceManager; + } + + public SchedulerImpl define(String name) { + return new SchedulerImpl(name, this.manager()); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/TaskHubImpl.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/TaskHubImpl.java new file mode 100644 index 0000000000000..2ab5a9df013ce --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/TaskHubImpl.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.implementation; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.durabletask.fluent.models.TaskHubInner; +import com.azure.resourcemanager.durabletask.models.TaskHub; +import com.azure.resourcemanager.durabletask.models.TaskHubProperties; + +public final class TaskHubImpl implements TaskHub, TaskHub.Definition, TaskHub.Update { + private TaskHubInner innerObject; + + private final com.azure.resourcemanager.durabletask.DurableTaskManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public TaskHubProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public TaskHubInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.durabletask.DurableTaskManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String schedulerName; + + private String taskHubName; + + public TaskHubImpl withExistingScheduler(String resourceGroupName, String schedulerName) { + this.resourceGroupName = resourceGroupName; + this.schedulerName = schedulerName; + return this; + } + + public TaskHub create() { + this.innerObject = serviceManager.serviceClient() + .getTaskHubs() + .createOrUpdate(resourceGroupName, schedulerName, taskHubName, this.innerModel(), Context.NONE); + return this; + } + + public TaskHub create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getTaskHubs() + .createOrUpdate(resourceGroupName, schedulerName, taskHubName, this.innerModel(), context); + return this; + } + + TaskHubImpl(String name, com.azure.resourcemanager.durabletask.DurableTaskManager serviceManager) { + this.innerObject = new TaskHubInner(); + this.serviceManager = serviceManager; + this.taskHubName = name; + } + + public TaskHubImpl update() { + return this; + } + + public TaskHub apply() { + this.innerObject = serviceManager.serviceClient() + .getTaskHubs() + .createOrUpdate(resourceGroupName, schedulerName, taskHubName, this.innerModel(), Context.NONE); + return this; + } + + public TaskHub apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getTaskHubs() + .createOrUpdate(resourceGroupName, schedulerName, taskHubName, this.innerModel(), context); + return this; + } + + TaskHubImpl(TaskHubInner innerObject, com.azure.resourcemanager.durabletask.DurableTaskManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.schedulerName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "schedulers"); + this.taskHubName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "taskHubs"); + } + + public TaskHub refresh() { + this.innerObject = serviceManager.serviceClient() + .getTaskHubs() + .getWithResponse(resourceGroupName, schedulerName, taskHubName, Context.NONE) + .getValue(); + return this; + } + + public TaskHub refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getTaskHubs() + .getWithResponse(resourceGroupName, schedulerName, taskHubName, context) + .getValue(); + return this; + } + + public TaskHubImpl withProperties(TaskHubProperties properties) { + this.innerModel().withProperties(properties); + return this; + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/TaskHubsClientImpl.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/TaskHubsClientImpl.java new file mode 100644 index 0000000000000..2ea67bd556768 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/TaskHubsClientImpl.java @@ -0,0 +1,918 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.durabletask.fluent.TaskHubsClient; +import com.azure.resourcemanager.durabletask.fluent.models.TaskHubInner; +import com.azure.resourcemanager.durabletask.implementation.models.TaskHubListResult; +import java.nio.ByteBuffer; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in TaskHubsClient. + */ +public final class TaskHubsClientImpl implements TaskHubsClient { + /** + * The proxy service used to perform REST calls. + */ + private final TaskHubsService service; + + /** + * The service client containing this operation class. + */ + private final DurableTaskClientImpl client; + + /** + * Initializes an instance of TaskHubsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + TaskHubsClientImpl(DurableTaskClientImpl client) { + this.service = RestProxy.create(TaskHubsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DurableTaskClientTaskHubs to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "DurableTaskClientTas") + public interface TaskHubsService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DurableTask/schedulers/{schedulerName}/taskHubs/{taskHubName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("schedulerName") String schedulerName, + @PathParam("taskHubName") String taskHubName, @HeaderParam("Accept") String accept, Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DurableTask/schedulers/{schedulerName}/taskHubs/{taskHubName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("schedulerName") String schedulerName, + @PathParam("taskHubName") String taskHubName, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") TaskHubInner resource, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DurableTask/schedulers/{schedulerName}/taskHubs/{taskHubName}") + @ExpectedResponses({ 202, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("schedulerName") String schedulerName, + @PathParam("taskHubName") String taskHubName, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DurableTask/schedulers/{schedulerName}/taskHubs") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByScheduler(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("schedulerName") String schedulerName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listBySchedulerNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * Get a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Task Hub along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName, String schedulerName, + String taskHubName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (schedulerName == null) { + return Mono.error(new IllegalArgumentException("Parameter schedulerName is required and cannot be null.")); + } + if (taskHubName == null) { + return Mono.error(new IllegalArgumentException("Parameter taskHubName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, schedulerName, taskHubName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Task Hub along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName, String schedulerName, + String taskHubName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (schedulerName == null) { + return Mono.error(new IllegalArgumentException("Parameter schedulerName is required and cannot be null.")); + } + if (taskHubName == null) { + return Mono.error(new IllegalArgumentException("Parameter taskHubName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.get(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, schedulerName, taskHubName, accept, context); + } + + /** + * Get a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Task Hub on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String resourceGroupName, String schedulerName, String taskHubName) { + return getWithResponseAsync(resourceGroupName, schedulerName, taskHubName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Task Hub along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String resourceGroupName, String schedulerName, String taskHubName, + Context context) { + return getWithResponseAsync(resourceGroupName, schedulerName, taskHubName, context).block(); + } + + /** + * Get a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Task Hub. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TaskHubInner get(String resourceGroupName, String schedulerName, String taskHubName) { + return getWithResponse(resourceGroupName, schedulerName, taskHubName, Context.NONE).getValue(); + } + + /** + * Create or Update a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Task Hub resource belonging to the scheduler along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, + String schedulerName, String taskHubName, TaskHubInner resource) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (schedulerName == null) { + return Mono.error(new IllegalArgumentException("Parameter schedulerName is required and cannot be null.")); + } + if (taskHubName == null) { + return Mono.error(new IllegalArgumentException("Parameter taskHubName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, schedulerName, taskHubName, contentType, accept, + resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create or Update a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Task Hub resource belonging to the scheduler along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, + String schedulerName, String taskHubName, TaskHubInner resource, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (schedulerName == null) { + return Mono.error(new IllegalArgumentException("Parameter schedulerName is required and cannot be null.")); + } + if (taskHubName == null) { + return Mono.error(new IllegalArgumentException("Parameter taskHubName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, schedulerName, taskHubName, contentType, accept, + resource, context); + } + + /** + * Create or Update a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of a Task Hub resource belonging to the scheduler. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, TaskHubInner> beginCreateOrUpdateAsync(String resourceGroupName, + String schedulerName, String taskHubName, TaskHubInner resource) { + Mono>> mono + = createOrUpdateWithResponseAsync(resourceGroupName, schedulerName, taskHubName, resource); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + TaskHubInner.class, TaskHubInner.class, this.client.getContext()); + } + + /** + * Create or Update a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of a Task Hub resource belonging to the scheduler. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, TaskHubInner> beginCreateOrUpdateAsync(String resourceGroupName, + String schedulerName, String taskHubName, TaskHubInner resource, Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = createOrUpdateWithResponseAsync(resourceGroupName, schedulerName, taskHubName, resource, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + TaskHubInner.class, TaskHubInner.class, context); + } + + /** + * Create or Update a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of a Task Hub resource belonging to the scheduler. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, TaskHubInner> beginCreateOrUpdate(String resourceGroupName, + String schedulerName, String taskHubName, TaskHubInner resource) { + return this.beginCreateOrUpdateAsync(resourceGroupName, schedulerName, taskHubName, resource).getSyncPoller(); + } + + /** + * Create or Update a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of a Task Hub resource belonging to the scheduler. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, TaskHubInner> beginCreateOrUpdate(String resourceGroupName, + String schedulerName, String taskHubName, TaskHubInner resource, Context context) { + return this.beginCreateOrUpdateAsync(resourceGroupName, schedulerName, taskHubName, resource, context) + .getSyncPoller(); + } + + /** + * Create or Update a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Task Hub resource belonging to the scheduler on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String schedulerName, String taskHubName, + TaskHubInner resource) { + return beginCreateOrUpdateAsync(resourceGroupName, schedulerName, taskHubName, resource).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create or Update a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Task Hub resource belonging to the scheduler on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String schedulerName, String taskHubName, + TaskHubInner resource, Context context) { + return beginCreateOrUpdateAsync(resourceGroupName, schedulerName, taskHubName, resource, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create or Update a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Task Hub resource belonging to the scheduler. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TaskHubInner createOrUpdate(String resourceGroupName, String schedulerName, String taskHubName, + TaskHubInner resource) { + return createOrUpdateAsync(resourceGroupName, schedulerName, taskHubName, resource).block(); + } + + /** + * Create or Update a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Task Hub resource belonging to the scheduler. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TaskHubInner createOrUpdate(String resourceGroupName, String schedulerName, String taskHubName, + TaskHubInner resource, Context context) { + return createOrUpdateAsync(resourceGroupName, schedulerName, taskHubName, resource, context).block(); + } + + /** + * Delete a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> deleteWithResponseAsync(String resourceGroupName, String schedulerName, + String taskHubName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (schedulerName == null) { + return Mono.error(new IllegalArgumentException("Parameter schedulerName is required and cannot be null.")); + } + if (taskHubName == null) { + return Mono.error(new IllegalArgumentException("Parameter taskHubName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, schedulerName, taskHubName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> deleteWithResponseAsync(String resourceGroupName, String schedulerName, + String taskHubName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (schedulerName == null) { + return Mono.error(new IllegalArgumentException("Parameter schedulerName is required and cannot be null.")); + } + if (taskHubName == null) { + return Mono.error(new IllegalArgumentException("Parameter taskHubName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.delete(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, schedulerName, taskHubName, accept, context); + } + + /** + * Delete a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, String schedulerName, + String taskHubName) { + Mono>> mono = deleteWithResponseAsync(resourceGroupName, schedulerName, taskHubName); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + this.client.getContext()); + } + + /** + * Delete a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, String schedulerName, + String taskHubName, Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = deleteWithResponseAsync(resourceGroupName, schedulerName, taskHubName, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + context); + } + + /** + * Delete a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, String schedulerName, + String taskHubName) { + return this.beginDeleteAsync(resourceGroupName, schedulerName, taskHubName).getSyncPoller(); + } + + /** + * Delete a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, String schedulerName, + String taskHubName, Context context) { + return this.beginDeleteAsync(resourceGroupName, schedulerName, taskHubName, context).getSyncPoller(); + } + + /** + * Delete a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String schedulerName, String taskHubName) { + return beginDeleteAsync(resourceGroupName, schedulerName, taskHubName).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String schedulerName, String taskHubName, + Context context) { + return beginDeleteAsync(resourceGroupName, schedulerName, taskHubName, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String schedulerName, String taskHubName) { + deleteAsync(resourceGroupName, schedulerName, taskHubName).block(); + } + + /** + * Delete a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String schedulerName, String taskHubName, Context context) { + deleteAsync(resourceGroupName, schedulerName, taskHubName, context).block(); + } + + /** + * List Task Hubs. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TaskHub list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySchedulerSinglePageAsync(String resourceGroupName, + String schedulerName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (schedulerName == null) { + return Mono.error(new IllegalArgumentException("Parameter schedulerName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByScheduler(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, schedulerName, accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List Task Hubs. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TaskHub list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySchedulerSinglePageAsync(String resourceGroupName, + String schedulerName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (schedulerName == null) { + return Mono.error(new IllegalArgumentException("Parameter schedulerName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByScheduler(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, schedulerName, accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List Task Hubs. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TaskHub list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listBySchedulerAsync(String resourceGroupName, String schedulerName) { + return new PagedFlux<>(() -> listBySchedulerSinglePageAsync(resourceGroupName, schedulerName), + nextLink -> listBySchedulerNextSinglePageAsync(nextLink)); + } + + /** + * List Task Hubs. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TaskHub list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listBySchedulerAsync(String resourceGroupName, String schedulerName, + Context context) { + return new PagedFlux<>(() -> listBySchedulerSinglePageAsync(resourceGroupName, schedulerName, context), + nextLink -> listBySchedulerNextSinglePageAsync(nextLink, context)); + } + + /** + * List Task Hubs. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TaskHub list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByScheduler(String resourceGroupName, String schedulerName) { + return new PagedIterable<>(listBySchedulerAsync(resourceGroupName, schedulerName)); + } + + /** + * List Task Hubs. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TaskHub list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByScheduler(String resourceGroupName, String schedulerName, + Context context) { + return new PagedIterable<>(listBySchedulerAsync(resourceGroupName, schedulerName, context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TaskHub list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySchedulerNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listBySchedulerNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TaskHub list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySchedulerNextSinglePageAsync(String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listBySchedulerNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/TaskHubsImpl.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/TaskHubsImpl.java new file mode 100644 index 0000000000000..8b3932123efb1 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/TaskHubsImpl.java @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.durabletask.fluent.TaskHubsClient; +import com.azure.resourcemanager.durabletask.fluent.models.TaskHubInner; +import com.azure.resourcemanager.durabletask.models.TaskHub; +import com.azure.resourcemanager.durabletask.models.TaskHubs; + +public final class TaskHubsImpl implements TaskHubs { + private static final ClientLogger LOGGER = new ClientLogger(TaskHubsImpl.class); + + private final TaskHubsClient innerClient; + + private final com.azure.resourcemanager.durabletask.DurableTaskManager serviceManager; + + public TaskHubsImpl(TaskHubsClient innerClient, + com.azure.resourcemanager.durabletask.DurableTaskManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getWithResponse(String resourceGroupName, String schedulerName, String taskHubName, + Context context) { + Response inner + = this.serviceClient().getWithResponse(resourceGroupName, schedulerName, taskHubName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new TaskHubImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public TaskHub get(String resourceGroupName, String schedulerName, String taskHubName) { + TaskHubInner inner = this.serviceClient().get(resourceGroupName, schedulerName, taskHubName); + if (inner != null) { + return new TaskHubImpl(inner, this.manager()); + } else { + return null; + } + } + + public void delete(String resourceGroupName, String schedulerName, String taskHubName) { + this.serviceClient().delete(resourceGroupName, schedulerName, taskHubName); + } + + public void delete(String resourceGroupName, String schedulerName, String taskHubName, Context context) { + this.serviceClient().delete(resourceGroupName, schedulerName, taskHubName, context); + } + + public PagedIterable listByScheduler(String resourceGroupName, String schedulerName) { + PagedIterable inner = this.serviceClient().listByScheduler(resourceGroupName, schedulerName); + return ResourceManagerUtils.mapPage(inner, inner1 -> new TaskHubImpl(inner1, this.manager())); + } + + public PagedIterable listByScheduler(String resourceGroupName, String schedulerName, Context context) { + PagedIterable inner + = this.serviceClient().listByScheduler(resourceGroupName, schedulerName, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new TaskHubImpl(inner1, this.manager())); + } + + public TaskHub getById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String schedulerName = ResourceManagerUtils.getValueFromIdByName(id, "schedulers"); + if (schedulerName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'schedulers'.", id))); + } + String taskHubName = ResourceManagerUtils.getValueFromIdByName(id, "taskHubs"); + if (taskHubName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'taskHubs'.", id))); + } + return this.getWithResponse(resourceGroupName, schedulerName, taskHubName, Context.NONE).getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String schedulerName = ResourceManagerUtils.getValueFromIdByName(id, "schedulers"); + if (schedulerName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'schedulers'.", id))); + } + String taskHubName = ResourceManagerUtils.getValueFromIdByName(id, "taskHubs"); + if (taskHubName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'taskHubs'.", id))); + } + return this.getWithResponse(resourceGroupName, schedulerName, taskHubName, context); + } + + public void deleteById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String schedulerName = ResourceManagerUtils.getValueFromIdByName(id, "schedulers"); + if (schedulerName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'schedulers'.", id))); + } + String taskHubName = ResourceManagerUtils.getValueFromIdByName(id, "taskHubs"); + if (taskHubName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'taskHubs'.", id))); + } + this.delete(resourceGroupName, schedulerName, taskHubName, Context.NONE); + } + + public void deleteByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String schedulerName = ResourceManagerUtils.getValueFromIdByName(id, "schedulers"); + if (schedulerName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'schedulers'.", id))); + } + String taskHubName = ResourceManagerUtils.getValueFromIdByName(id, "taskHubs"); + if (taskHubName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'taskHubs'.", id))); + } + this.delete(resourceGroupName, schedulerName, taskHubName, context); + } + + private TaskHubsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.durabletask.DurableTaskManager manager() { + return this.serviceManager; + } + + public TaskHubImpl define(String name) { + return new TaskHubImpl(name, this.manager()); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/models/OperationListResult.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/models/OperationListResult.java new file mode 100644 index 0000000000000..b6a9cfba66937 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/models/OperationListResult.java @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.durabletask.fluent.models.OperationInner; +import java.io.IOException; +import java.util.List; + +/** + * A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of + * results. + */ +@Immutable +public final class OperationListResult implements JsonSerializable { + /* + * The Operation items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of OperationListResult class. + */ + private OperationListResult() { + } + + /** + * Get the value property: The Operation items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property value in model OperationListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(OperationListResult.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationListResult if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the OperationListResult. + */ + public static OperationListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationListResult deserializedOperationListResult = new OperationListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> OperationInner.fromJson(reader1)); + deserializedOperationListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedOperationListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationListResult; + }); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/models/SchedulerListResult.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/models/SchedulerListResult.java new file mode 100644 index 0000000000000..1ab772b008b65 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/models/SchedulerListResult.java @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.durabletask.fluent.models.SchedulerInner; +import java.io.IOException; +import java.util.List; + +/** + * The response of a Scheduler list operation. + */ +@Immutable +public final class SchedulerListResult implements JsonSerializable { + /* + * The Scheduler items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of SchedulerListResult class. + */ + private SchedulerListResult() { + } + + /** + * Get the value property: The Scheduler items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property value in model SchedulerListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(SchedulerListResult.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SchedulerListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SchedulerListResult if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SchedulerListResult. + */ + public static SchedulerListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SchedulerListResult deserializedSchedulerListResult = new SchedulerListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> SchedulerInner.fromJson(reader1)); + deserializedSchedulerListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedSchedulerListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedSchedulerListResult; + }); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/models/TaskHubListResult.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/models/TaskHubListResult.java new file mode 100644 index 0000000000000..d0cd8685d95c1 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/models/TaskHubListResult.java @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.durabletask.fluent.models.TaskHubInner; +import java.io.IOException; +import java.util.List; + +/** + * The response of a TaskHub list operation. + */ +@Immutable +public final class TaskHubListResult implements JsonSerializable { + /* + * The TaskHub items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of TaskHubListResult class. + */ + private TaskHubListResult() { + } + + /** + * Get the value property: The TaskHub items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property value in model TaskHubListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(TaskHubListResult.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TaskHubListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TaskHubListResult if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the TaskHubListResult. + */ + public static TaskHubListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TaskHubListResult deserializedTaskHubListResult = new TaskHubListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> TaskHubInner.fromJson(reader1)); + deserializedTaskHubListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedTaskHubListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedTaskHubListResult; + }); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/package-info.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/package-info.java new file mode 100644 index 0000000000000..a20ea1bf903ad --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/implementation/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for DurableTask. + */ +package com.azure.resourcemanager.durabletask.implementation; diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/ActionType.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/ActionType.java new file mode 100644 index 0000000000000..81e7e501aeb43 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/ActionType.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + */ +public final class ActionType extends ExpandableStringEnum { + /** + * Actions are for internal-only APIs. + */ + public static final ActionType INTERNAL = fromString("Internal"); + + /** + * Creates a new instance of ActionType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ActionType() { + } + + /** + * Creates or finds a ActionType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ActionType. + */ + public static ActionType fromString(String name) { + return fromString(name, ActionType.class); + } + + /** + * Gets known ActionType values. + * + * @return known ActionType values. + */ + public static Collection values() { + return values(ActionType.class); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/Operation.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/Operation.java new file mode 100644 index 0000000000000..773534cc05f5c --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/Operation.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.models; + +import com.azure.resourcemanager.durabletask.fluent.models.OperationInner; + +/** + * An immutable client-side representation of Operation. + */ +public interface Operation { + /** + * Gets the name property: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + * + * @return the name value. + */ + String name(); + + /** + * Gets the isDataAction property: Whether the operation applies to data-plane. This is "true" for data-plane + * operations and "false" for Azure Resource Manager/control-plane operations. + * + * @return the isDataAction value. + */ + Boolean isDataAction(); + + /** + * Gets the display property: Localized display information for this particular operation. + * + * @return the display value. + */ + OperationDisplay display(); + + /** + * Gets the origin property: The intended executor of the operation; as in Resource Based Access Control (RBAC) and + * audit logs UX. Default value is "user,system". + * + * @return the origin value. + */ + Origin origin(); + + /** + * Gets the actionType property: Extensible enum. Indicates the action type. "Internal" refers to actions that are + * for internal only APIs. + * + * @return the actionType value. + */ + ActionType actionType(); + + /** + * Gets the inner com.azure.resourcemanager.durabletask.fluent.models.OperationInner object. + * + * @return the inner object. + */ + OperationInner innerModel(); +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/OperationDisplay.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/OperationDisplay.java new file mode 100644 index 0000000000000..352f0d16ac235 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/OperationDisplay.java @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Localized display information for and operation. + */ +@Immutable +public final class OperationDisplay implements JsonSerializable { + /* + * The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or + * "Microsoft Compute". + */ + private String provider; + + /* + * The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or + * "Job Schedule Collections". + */ + private String resource; + + /* + * The concise, localized friendly name for the operation; suitable for dropdowns. E.g. + * "Create or Update Virtual Machine", "Restart Virtual Machine". + */ + private String operation; + + /* + * The short, localized friendly description of the operation; suitable for tool tips and detailed views. + */ + private String description; + + /** + * Creates an instance of OperationDisplay class. + */ + private OperationDisplay() { + } + + /** + * Get the provider property: The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring + * Insights" or "Microsoft Compute". + * + * @return the provider value. + */ + public String provider() { + return this.provider; + } + + /** + * Get the resource property: The localized friendly name of the resource type related to this operation. E.g. + * "Virtual Machines" or "Job Schedule Collections". + * + * @return the resource value. + */ + public String resource() { + return this.resource; + } + + /** + * Get the operation property: The concise, localized friendly name for the operation; suitable for dropdowns. E.g. + * "Create or Update Virtual Machine", "Restart Virtual Machine". + * + * @return the operation value. + */ + public String operation() { + return this.operation; + } + + /** + * Get the description property: The short, localized friendly description of the operation; suitable for tool tips + * and detailed views. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationDisplay from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationDisplay if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the OperationDisplay. + */ + public static OperationDisplay fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationDisplay deserializedOperationDisplay = new OperationDisplay(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("provider".equals(fieldName)) { + deserializedOperationDisplay.provider = reader.getString(); + } else if ("resource".equals(fieldName)) { + deserializedOperationDisplay.resource = reader.getString(); + } else if ("operation".equals(fieldName)) { + deserializedOperationDisplay.operation = reader.getString(); + } else if ("description".equals(fieldName)) { + deserializedOperationDisplay.description = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationDisplay; + }); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/Operations.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/Operations.java new file mode 100644 index 0000000000000..60ecd26bbf4ed --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/Operations.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; + +/** + * Resource collection API of Operations. + */ +public interface Operations { + /** + * List the operations for the provider. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + PagedIterable list(); + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + PagedIterable list(Context context); +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/Origin.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/Origin.java new file mode 100644 index 0000000000000..5b51232c14f15 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/Origin.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value + * is "user,system". + */ +public final class Origin extends ExpandableStringEnum { + /** + * Indicates the operation is initiated by a user. + */ + public static final Origin USER = fromString("user"); + + /** + * Indicates the operation is initiated by a system. + */ + public static final Origin SYSTEM = fromString("system"); + + /** + * Indicates the operation is initiated by a user or system. + */ + public static final Origin USER_SYSTEM = fromString("user,system"); + + /** + * Creates a new instance of Origin value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public Origin() { + } + + /** + * Creates or finds a Origin from its string representation. + * + * @param name a name to look for. + * @return the corresponding Origin. + */ + public static Origin fromString(String name) { + return fromString(name, Origin.class); + } + + /** + * Gets known Origin values. + * + * @return known Origin values. + */ + public static Collection values() { + return values(Origin.class); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/ProvisioningState.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/ProvisioningState.java new file mode 100644 index 0000000000000..15de90cebd2b9 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/ProvisioningState.java @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The status of the current operation. + */ +public final class ProvisioningState extends ExpandableStringEnum { + /** + * Resource has been created. + */ + public static final ProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** + * Resource creation failed. + */ + public static final ProvisioningState FAILED = fromString("Failed"); + + /** + * Resource creation was canceled. + */ + public static final ProvisioningState CANCELED = fromString("Canceled"); + + /** + * The resource is being provisioned. + */ + public static final ProvisioningState PROVISIONING = fromString("Provisioning"); + + /** + * The resource is updating. + */ + public static final ProvisioningState UPDATING = fromString("Updating"); + + /** + * The resource is being deleted. + */ + public static final ProvisioningState DELETING = fromString("Deleting"); + + /** + * The resource create request has been accepted. + */ + public static final ProvisioningState ACCEPTED = fromString("Accepted"); + + /** + * Creates a new instance of ProvisioningState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ProvisioningState() { + } + + /** + * Creates or finds a ProvisioningState from its string representation. + * + * @param name a name to look for. + * @return the corresponding ProvisioningState. + */ + public static ProvisioningState fromString(String name) { + return fromString(name, ProvisioningState.class); + } + + /** + * Gets known ProvisioningState values. + * + * @return known ProvisioningState values. + */ + public static Collection values() { + return values(ProvisioningState.class); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/RedundancyState.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/RedundancyState.java new file mode 100644 index 0000000000000..9d3752c19e468 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/RedundancyState.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The state of the resource redundancy. + */ +public final class RedundancyState extends ExpandableStringEnum { + /** + * The resource is not redundant. + */ + public static final RedundancyState NONE = fromString("None"); + + /** + * The resource is zone redundant. + */ + public static final RedundancyState ZONE = fromString("Zone"); + + /** + * Creates a new instance of RedundancyState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public RedundancyState() { + } + + /** + * Creates or finds a RedundancyState from its string representation. + * + * @param name a name to look for. + * @return the corresponding RedundancyState. + */ + public static RedundancyState fromString(String name) { + return fromString(name, RedundancyState.class); + } + + /** + * Gets known RedundancyState values. + * + * @return known RedundancyState values. + */ + public static Collection values() { + return values(RedundancyState.class); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/Scheduler.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/Scheduler.java new file mode 100644 index 0000000000000..b84a3716cd762 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/Scheduler.java @@ -0,0 +1,265 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.models; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.durabletask.fluent.models.SchedulerInner; +import java.util.Map; + +/** + * An immutable client-side representation of Scheduler. + */ +public interface Scheduler { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the location property: The geo-location where the resource lives. + * + * @return the location value. + */ + String location(); + + /** + * Gets the tags property: Resource tags. + * + * @return the tags value. + */ + Map tags(); + + /** + * Gets the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + SchedulerProperties properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the region of the resource. + * + * @return the region of the resource. + */ + Region region(); + + /** + * Gets the name of the resource region. + * + * @return the name of the resource region. + */ + String regionName(); + + /** + * Gets the name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner com.azure.resourcemanager.durabletask.fluent.models.SchedulerInner object. + * + * @return the inner object. + */ + SchedulerInner innerModel(); + + /** + * The entirety of the Scheduler definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, DefinitionStages.WithCreate { + } + + /** + * The Scheduler definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the Scheduler definition. + */ + interface Blank extends WithLocation { + } + + /** + * The stage of the Scheduler definition allowing to specify location. + */ + interface WithLocation { + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(Region location); + + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(String location); + } + + /** + * The stage of the Scheduler definition allowing to specify parent resource. + */ + interface WithResourceGroup { + /** + * Specifies resourceGroupName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @return the next definition stage. + */ + WithCreate withExistingResourceGroup(String resourceGroupName); + } + + /** + * The stage of the Scheduler definition which contains all the minimum required properties for the resource to + * be created, but also allows for any other optional properties to be specified. + */ + interface WithCreate extends DefinitionStages.WithTags, DefinitionStages.WithProperties { + /** + * Executes the create request. + * + * @return the created resource. + */ + Scheduler create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + Scheduler create(Context context); + } + + /** + * The stage of the Scheduler definition allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + WithCreate withTags(Map tags); + } + + /** + * The stage of the Scheduler definition allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + WithCreate withProperties(SchedulerProperties properties); + } + } + + /** + * Begins update for the Scheduler resource. + * + * @return the stage of resource update. + */ + Scheduler.Update update(); + + /** + * The template for Scheduler update. + */ + interface Update extends UpdateStages.WithTags, UpdateStages.WithProperties { + /** + * Executes the update request. + * + * @return the updated resource. + */ + Scheduler apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + Scheduler apply(Context context); + } + + /** + * The Scheduler update stages. + */ + interface UpdateStages { + /** + * The stage of the Scheduler update allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + Update withTags(Map tags); + } + + /** + * The stage of the Scheduler update allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + Update withProperties(SchedulerProperties properties); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + Scheduler refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + Scheduler refresh(Context context); +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/SchedulerProperties.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/SchedulerProperties.java new file mode 100644 index 0000000000000..d1da90798a9d6 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/SchedulerProperties.java @@ -0,0 +1,171 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Details of the Scheduler. + */ +@Fluent +public final class SchedulerProperties implements JsonSerializable { + /* + * The status of the last operation + */ + private ProvisioningState provisioningState; + + /* + * URL of the durable task scheduler + */ + private String endpoint; + + /* + * IP allow list for durable task scheduler. Values can be IPv4, IPv6 or CIDR + */ + private List ipAllowlist; + + /* + * SKU of the durable task scheduler + */ + private SchedulerSku sku; + + /** + * Creates an instance of SchedulerProperties class. + */ + public SchedulerProperties() { + } + + /** + * Get the provisioningState property: The status of the last operation. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the endpoint property: URL of the durable task scheduler. + * + * @return the endpoint value. + */ + public String endpoint() { + return this.endpoint; + } + + /** + * Get the ipAllowlist property: IP allow list for durable task scheduler. Values can be IPv4, IPv6 or CIDR. + * + * @return the ipAllowlist value. + */ + public List ipAllowlist() { + return this.ipAllowlist; + } + + /** + * Set the ipAllowlist property: IP allow list for durable task scheduler. Values can be IPv4, IPv6 or CIDR. + * + * @param ipAllowlist the ipAllowlist value to set. + * @return the SchedulerProperties object itself. + */ + public SchedulerProperties withIpAllowlist(List ipAllowlist) { + this.ipAllowlist = ipAllowlist; + return this; + } + + /** + * Get the sku property: SKU of the durable task scheduler. + * + * @return the sku value. + */ + public SchedulerSku sku() { + return this.sku; + } + + /** + * Set the sku property: SKU of the durable task scheduler. + * + * @param sku the sku value to set. + * @return the SchedulerProperties object itself. + */ + public SchedulerProperties withSku(SchedulerSku sku) { + this.sku = sku; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (ipAllowlist() == null) { + throw LOGGER.atError() + .log( + new IllegalArgumentException("Missing required property ipAllowlist in model SchedulerProperties")); + } + if (sku() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property sku in model SchedulerProperties")); + } else { + sku().validate(); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(SchedulerProperties.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("ipAllowlist", this.ipAllowlist, (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("sku", this.sku); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SchedulerProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SchedulerProperties if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SchedulerProperties. + */ + public static SchedulerProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SchedulerProperties deserializedSchedulerProperties = new SchedulerProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("ipAllowlist".equals(fieldName)) { + List ipAllowlist = reader.readArray(reader1 -> reader1.getString()); + deserializedSchedulerProperties.ipAllowlist = ipAllowlist; + } else if ("sku".equals(fieldName)) { + deserializedSchedulerProperties.sku = SchedulerSku.fromJson(reader); + } else if ("provisioningState".equals(fieldName)) { + deserializedSchedulerProperties.provisioningState + = ProvisioningState.fromString(reader.getString()); + } else if ("endpoint".equals(fieldName)) { + deserializedSchedulerProperties.endpoint = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedSchedulerProperties; + }); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/SchedulerSku.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/SchedulerSku.java new file mode 100644 index 0000000000000..7cc4210f73ea2 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/SchedulerSku.java @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The SKU (Stock Keeping Unit) assigned to this durable task scheduler. + */ +@Fluent +public final class SchedulerSku implements JsonSerializable { + /* + * The name of the SKU + */ + private String name; + + /* + * The SKU capacity. This allows scale out/in for the resource and impacts zone redundancy + */ + private Integer capacity; + + /* + * Indicates whether the current SKU configuration is zone redundant + */ + private RedundancyState redundancyState; + + /** + * Creates an instance of SchedulerSku class. + */ + public SchedulerSku() { + } + + /** + * Get the name property: The name of the SKU. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: The name of the SKU. + * + * @param name the name value to set. + * @return the SchedulerSku object itself. + */ + public SchedulerSku withName(String name) { + this.name = name; + return this; + } + + /** + * Get the capacity property: The SKU capacity. This allows scale out/in for the resource and impacts zone + * redundancy. + * + * @return the capacity value. + */ + public Integer capacity() { + return this.capacity; + } + + /** + * Set the capacity property: The SKU capacity. This allows scale out/in for the resource and impacts zone + * redundancy. + * + * @param capacity the capacity value to set. + * @return the SchedulerSku object itself. + */ + public SchedulerSku withCapacity(Integer capacity) { + this.capacity = capacity; + return this; + } + + /** + * Get the redundancyState property: Indicates whether the current SKU configuration is zone redundant. + * + * @return the redundancyState value. + */ + public RedundancyState redundancyState() { + return this.redundancyState; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property name in model SchedulerSku")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(SchedulerSku.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeNumberField("capacity", this.capacity); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SchedulerSku from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SchedulerSku if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SchedulerSku. + */ + public static SchedulerSku fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SchedulerSku deserializedSchedulerSku = new SchedulerSku(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedSchedulerSku.name = reader.getString(); + } else if ("capacity".equals(fieldName)) { + deserializedSchedulerSku.capacity = reader.getNullable(JsonReader::getInt); + } else if ("redundancyState".equals(fieldName)) { + deserializedSchedulerSku.redundancyState = RedundancyState.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedSchedulerSku; + }); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/Schedulers.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/Schedulers.java new file mode 100644 index 0000000000000..36ea7bd90df88 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/Schedulers.java @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of Schedulers. + */ +public interface Schedulers { + /** + * Get a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Scheduler along with {@link Response}. + */ + Response getByResourceGroupWithResponse(String resourceGroupName, String schedulerName, Context context); + + /** + * Get a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Scheduler. + */ + Scheduler getByResourceGroup(String resourceGroupName, String schedulerName); + + /** + * Delete a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteByResourceGroup(String resourceGroupName, String schedulerName); + + /** + * Delete a Scheduler. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void delete(String resourceGroupName, String schedulerName, Context context); + + /** + * List Schedulers by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * List Schedulers by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * List Schedulers by subscription. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable list(); + + /** + * List Schedulers by subscription. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Scheduler list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable list(Context context); + + /** + * Get a Scheduler. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Scheduler along with {@link Response}. + */ + Scheduler getById(String id); + + /** + * Get a Scheduler. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Scheduler along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a Scheduler. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteById(String id); + + /** + * Delete a Scheduler. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new Scheduler resource. + * + * @param name resource name. + * @return the first stage of the new Scheduler definition. + */ + Scheduler.DefinitionStages.Blank define(String name); +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/TaskHub.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/TaskHub.java new file mode 100644 index 0000000000000..a3f8455cc7063 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/TaskHub.java @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.models; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.durabletask.fluent.models.TaskHubInner; + +/** + * An immutable client-side representation of TaskHub. + */ +public interface TaskHub { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + TaskHubProperties properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner com.azure.resourcemanager.durabletask.fluent.models.TaskHubInner object. + * + * @return the inner object. + */ + TaskHubInner innerModel(); + + /** + * The entirety of the TaskHub definition. + */ + interface Definition + extends DefinitionStages.Blank, DefinitionStages.WithParentResource, DefinitionStages.WithCreate { + } + + /** + * The TaskHub definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the TaskHub definition. + */ + interface Blank extends WithParentResource { + } + + /** + * The stage of the TaskHub definition allowing to specify parent resource. + */ + interface WithParentResource { + /** + * Specifies resourceGroupName, schedulerName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @return the next definition stage. + */ + WithCreate withExistingScheduler(String resourceGroupName, String schedulerName); + } + + /** + * The stage of the TaskHub definition which contains all the minimum required properties for the resource to be + * created, but also allows for any other optional properties to be specified. + */ + interface WithCreate extends DefinitionStages.WithProperties { + /** + * Executes the create request. + * + * @return the created resource. + */ + TaskHub create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + TaskHub create(Context context); + } + + /** + * The stage of the TaskHub definition allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + WithCreate withProperties(TaskHubProperties properties); + } + } + + /** + * Begins update for the TaskHub resource. + * + * @return the stage of resource update. + */ + TaskHub.Update update(); + + /** + * The template for TaskHub update. + */ + interface Update extends UpdateStages.WithProperties { + /** + * Executes the update request. + * + * @return the updated resource. + */ + TaskHub apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + TaskHub apply(Context context); + } + + /** + * The TaskHub update stages. + */ + interface UpdateStages { + /** + * The stage of the TaskHub update allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + Update withProperties(TaskHubProperties properties); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + TaskHub refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + TaskHub refresh(Context context); +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/TaskHubProperties.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/TaskHubProperties.java new file mode 100644 index 0000000000000..e8839dbea7709 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/TaskHubProperties.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The properties of Task Hub. + */ +@Immutable +public final class TaskHubProperties implements JsonSerializable { + /* + * The status of the last operation + */ + private ProvisioningState provisioningState; + + /* + * URL of the durable task scheduler dashboard + */ + private String dashboardUrl; + + /** + * Creates an instance of TaskHubProperties class. + */ + public TaskHubProperties() { + } + + /** + * Get the provisioningState property: The status of the last operation. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the dashboardUrl property: URL of the durable task scheduler dashboard. + * + * @return the dashboardUrl value. + */ + public String dashboardUrl() { + return this.dashboardUrl; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TaskHubProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TaskHubProperties if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the TaskHubProperties. + */ + public static TaskHubProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TaskHubProperties deserializedTaskHubProperties = new TaskHubProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("provisioningState".equals(fieldName)) { + deserializedTaskHubProperties.provisioningState = ProvisioningState.fromString(reader.getString()); + } else if ("dashboardUrl".equals(fieldName)) { + deserializedTaskHubProperties.dashboardUrl = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedTaskHubProperties; + }); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/TaskHubs.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/TaskHubs.java new file mode 100644 index 0000000000000..ad18e48cefe0e --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/TaskHubs.java @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of TaskHubs. + */ +public interface TaskHubs { + /** + * Get a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Task Hub along with {@link Response}. + */ + Response getWithResponse(String resourceGroupName, String schedulerName, String taskHubName, + Context context); + + /** + * Get a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Task Hub. + */ + TaskHub get(String resourceGroupName, String schedulerName, String taskHubName); + + /** + * Delete a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void delete(String resourceGroupName, String schedulerName, String taskHubName); + + /** + * Delete a Task Hub. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param taskHubName The name of the TaskHub. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void delete(String resourceGroupName, String schedulerName, String taskHubName, Context context); + + /** + * List Task Hubs. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TaskHub list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByScheduler(String resourceGroupName, String schedulerName); + + /** + * List Task Hubs. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param schedulerName The name of the Scheduler. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TaskHub list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByScheduler(String resourceGroupName, String schedulerName, Context context); + + /** + * Get a Task Hub. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Task Hub along with {@link Response}. + */ + TaskHub getById(String id); + + /** + * Get a Task Hub. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Task Hub along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a Task Hub. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteById(String id); + + /** + * Delete a Task Hub. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new TaskHub resource. + * + * @param name resource name. + * @return the first stage of the new TaskHub definition. + */ + TaskHub.DefinitionStages.Blank define(String name); +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/package-info.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/package-info.java new file mode 100644 index 0000000000000..5778ae3f6a9e0 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/models/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for DurableTask. + */ +package com.azure.resourcemanager.durabletask.models; diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/package-info.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/package-info.java new file mode 100644 index 0000000000000..4a0642458ee13 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/com/azure/resourcemanager/durabletask/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for DurableTask. + */ +package com.azure.resourcemanager.durabletask; diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/module-info.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/module-info.java new file mode 100644 index 0000000000000..922a71979d72b --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/java/module-info.java @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +module com.azure.resourcemanager.durabletask { + requires transitive com.azure.core.management; + + exports com.azure.resourcemanager.durabletask; + exports com.azure.resourcemanager.durabletask.fluent; + exports com.azure.resourcemanager.durabletask.fluent.models; + exports com.azure.resourcemanager.durabletask.models; + + opens com.azure.resourcemanager.durabletask.fluent.models to com.azure.core; + opens com.azure.resourcemanager.durabletask.models to com.azure.core; + opens com.azure.resourcemanager.durabletask.implementation.models to com.azure.core; +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-durabletask/proxy-config.json b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-durabletask/proxy-config.json new file mode 100644 index 0000000000000..4b7b3074fd519 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-durabletask/proxy-config.json @@ -0,0 +1 @@ +[["com.azure.resourcemanager.durabletask.implementation.OperationsClientImpl$OperationsService"],["com.azure.resourcemanager.durabletask.implementation.SchedulersClientImpl$SchedulersService"],["com.azure.resourcemanager.durabletask.implementation.TaskHubsClientImpl$TaskHubsService"]] \ No newline at end of file diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-durabletask/reflect-config.json b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-durabletask/reflect-config.json new file mode 100644 index 0000000000000..0637a088a01e8 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-durabletask/reflect-config.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/OperationsListSamples.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/OperationsListSamples.java new file mode 100644 index 0000000000000..b231a18a548fb --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/OperationsListSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +/** + * Samples for Operations List. + */ +public final class OperationsListSamples { + /* + * x-ms-original-file: 2024-10-01-preview/Operations_List.json + */ + /** + * Sample code: Operations_List. + * + * @param manager Entry point to DurableTaskManager. + */ + public static void operationsList(com.azure.resourcemanager.durabletask.DurableTaskManager manager) { + manager.operations().list(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersCreateOrUpdateSamples.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersCreateOrUpdateSamples.java new file mode 100644 index 0000000000000..d0df8bda6d241 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersCreateOrUpdateSamples.java @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +import com.azure.resourcemanager.durabletask.models.SchedulerProperties; +import com.azure.resourcemanager.durabletask.models.SchedulerSku; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for Schedulers CreateOrUpdate. + */ +public final class SchedulersCreateOrUpdateSamples { + /* + * x-ms-original-file: 2024-10-01-preview/Schedulers_CreateOrUpdate.json + */ + /** + * Sample code: Schedulers_CreateOrUpdate. + * + * @param manager Entry point to DurableTaskManager. + */ + public static void schedulersCreateOrUpdate(com.azure.resourcemanager.durabletask.DurableTaskManager manager) { + manager.schedulers() + .define("testscheduler") + .withRegion("northcentralus") + .withExistingResourceGroup("rgopenapi") + .withTags(mapOf("key7131", "fakeTokenPlaceholder", "key2138", "fakeTokenPlaceholder")) + .withProperties(new SchedulerProperties().withIpAllowlist(Arrays.asList("10.0.0.0/8")) + .withSku(new SchedulerSku().withName("Dedicated"))) + .create(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersDeleteSamples.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersDeleteSamples.java new file mode 100644 index 0000000000000..82c1efe618d75 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersDeleteSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +/** + * Samples for Schedulers Delete. + */ +public final class SchedulersDeleteSamples { + /* + * x-ms-original-file: 2024-10-01-preview/Schedulers_Delete.json + */ + /** + * Sample code: Schedulers_Delete. + * + * @param manager Entry point to DurableTaskManager. + */ + public static void schedulersDelete(com.azure.resourcemanager.durabletask.DurableTaskManager manager) { + manager.schedulers().delete("rgopenapi", "testscheduler", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersGetByResourceGroupSamples.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersGetByResourceGroupSamples.java new file mode 100644 index 0000000000000..6b6280411acb8 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersGetByResourceGroupSamples.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +/** + * Samples for Schedulers GetByResourceGroup. + */ +public final class SchedulersGetByResourceGroupSamples { + /* + * x-ms-original-file: 2024-10-01-preview/Schedulers_Get.json + */ + /** + * Sample code: Schedulers_Get. + * + * @param manager Entry point to DurableTaskManager. + */ + public static void schedulersGet(com.azure.resourcemanager.durabletask.DurableTaskManager manager) { + manager.schedulers() + .getByResourceGroupWithResponse("rgopenapi", "testscheduler", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersListByResourceGroupSamples.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersListByResourceGroupSamples.java new file mode 100644 index 0000000000000..b11f8064e2358 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersListByResourceGroupSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +/** + * Samples for Schedulers ListByResourceGroup. + */ +public final class SchedulersListByResourceGroupSamples { + /* + * x-ms-original-file: 2024-10-01-preview/Schedulers_ListByResourceGroup.json + */ + /** + * Sample code: Schedulers_ListByResourceGroup. + * + * @param manager Entry point to DurableTaskManager. + */ + public static void schedulersListByResourceGroup(com.azure.resourcemanager.durabletask.DurableTaskManager manager) { + manager.schedulers().listByResourceGroup("rgopenapi", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersListSamples.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersListSamples.java new file mode 100644 index 0000000000000..b7e12f4e0d2a9 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersListSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +/** + * Samples for Schedulers List. + */ +public final class SchedulersListSamples { + /* + * x-ms-original-file: 2024-10-01-preview/Schedulers_ListBySubscription.json + */ + /** + * Sample code: Schedulers_ListBySubscription. + * + * @param manager Entry point to DurableTaskManager. + */ + public static void schedulersListBySubscription(com.azure.resourcemanager.durabletask.DurableTaskManager manager) { + manager.schedulers().list(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersUpdateSamples.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersUpdateSamples.java new file mode 100644 index 0000000000000..a9a5f72aaa228 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/SchedulersUpdateSamples.java @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +import com.azure.resourcemanager.durabletask.models.Scheduler; +import com.azure.resourcemanager.durabletask.models.SchedulerProperties; +import com.azure.resourcemanager.durabletask.models.SchedulerSku; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for Schedulers Update. + */ +public final class SchedulersUpdateSamples { + /* + * x-ms-original-file: 2024-10-01-preview/Schedulers_Update.json + */ + /** + * Sample code: Schedulers_Update. + * + * @param manager Entry point to DurableTaskManager. + */ + public static void schedulersUpdate(com.azure.resourcemanager.durabletask.DurableTaskManager manager) { + Scheduler resource = manager.schedulers() + .getByResourceGroupWithResponse("rgopenapi", "testscheduler", com.azure.core.util.Context.NONE) + .getValue(); + resource.update() + .withTags(mapOf("key8653", "fakeTokenPlaceholder")) + .withProperties(new SchedulerProperties().withIpAllowlist(Arrays.asList("10.0.0.0/8")) + .withSku(new SchedulerSku().withName("Dedicated").withCapacity(10))) + .apply(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/TaskHubsCreateOrUpdateSamples.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/TaskHubsCreateOrUpdateSamples.java new file mode 100644 index 0000000000000..dfc27f36976c6 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/TaskHubsCreateOrUpdateSamples.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +import com.azure.resourcemanager.durabletask.models.TaskHubProperties; + +/** + * Samples for TaskHubs CreateOrUpdate. + */ +public final class TaskHubsCreateOrUpdateSamples { + /* + * x-ms-original-file: 2024-10-01-preview/TaskHubs_CreateOrUpdate.json + */ + /** + * Sample code: TaskHubs_CreateOrUpdate. + * + * @param manager Entry point to DurableTaskManager. + */ + public static void taskHubsCreateOrUpdate(com.azure.resourcemanager.durabletask.DurableTaskManager manager) { + manager.taskHubs() + .define("testtaskhub") + .withExistingScheduler("rgopenapi", "testscheduler") + .withProperties(new TaskHubProperties()) + .create(); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/TaskHubsDeleteSamples.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/TaskHubsDeleteSamples.java new file mode 100644 index 0000000000000..b0f04ead9c060 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/TaskHubsDeleteSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +/** + * Samples for TaskHubs Delete. + */ +public final class TaskHubsDeleteSamples { + /* + * x-ms-original-file: 2024-10-01-preview/TaskHubs_Delete.json + */ + /** + * Sample code: TaskHubs_Delete. + * + * @param manager Entry point to DurableTaskManager. + */ + public static void taskHubsDelete(com.azure.resourcemanager.durabletask.DurableTaskManager manager) { + manager.taskHubs().delete("rgopenapi", "testscheduler", "testtuskhub", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/TaskHubsGetSamples.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/TaskHubsGetSamples.java new file mode 100644 index 0000000000000..6f73418b94db4 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/TaskHubsGetSamples.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +/** + * Samples for TaskHubs Get. + */ +public final class TaskHubsGetSamples { + /* + * x-ms-original-file: 2024-10-01-preview/TaskHubs_Get.json + */ + /** + * Sample code: TaskHubs_Get. + * + * @param manager Entry point to DurableTaskManager. + */ + public static void taskHubsGet(com.azure.resourcemanager.durabletask.DurableTaskManager manager) { + manager.taskHubs() + .getWithResponse("rgopenapi", "testscheduler", "testtuskhub", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/TaskHubsListBySchedulerSamples.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/TaskHubsListBySchedulerSamples.java new file mode 100644 index 0000000000000..817352d06a54f --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/samples/java/com/azure/resourcemanager/durabletask/generated/TaskHubsListBySchedulerSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +/** + * Samples for TaskHubs ListByScheduler. + */ +public final class TaskHubsListBySchedulerSamples { + /* + * x-ms-original-file: 2024-10-01-preview/TaskHubs_ListByScheduler.json + */ + /** + * Sample code: TaskHubs_ListByScheduler. + * + * @param manager Entry point to DurableTaskManager. + */ + public static void taskHubsListByScheduler(com.azure.resourcemanager.durabletask.DurableTaskManager manager) { + manager.taskHubs().listByScheduler("rgopenapi", "testtaskhub", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/OperationDisplayTests.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/OperationDisplayTests.java new file mode 100644 index 0000000000000..d7671426f1df2 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/OperationDisplayTests.java @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.durabletask.models.OperationDisplay; + +public final class OperationDisplayTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + OperationDisplay model = BinaryData.fromString( + "{\"provider\":\"cdm\",\"resource\":\"rcryuanzwuxzdxta\",\"operation\":\"lhmwhfpmrqobm\",\"description\":\"kknryrtihf\"}") + .toObject(OperationDisplay.class); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/OperationInnerTests.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/OperationInnerTests.java new file mode 100644 index 0000000000000..42905b0069f9f --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/OperationInnerTests.java @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.durabletask.fluent.models.OperationInner; +import com.azure.resourcemanager.durabletask.models.ActionType; +import org.junit.jupiter.api.Assertions; + +public final class OperationInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + OperationInner model = BinaryData.fromString( + "{\"name\":\"nygj\",\"isDataAction\":true,\"display\":{\"provider\":\"eqsrdeupewnwreit\",\"resource\":\"yflusarhmofc\",\"operation\":\"smy\",\"description\":\"kdtmlxhekuk\"},\"origin\":\"user,system\",\"actionType\":\"Internal\"}") + .toObject(OperationInner.class); + Assertions.assertEquals(ActionType.INTERNAL, model.actionType()); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/OperationListResultTests.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/OperationListResultTests.java new file mode 100644 index 0000000000000..53556361f76af --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/OperationListResultTests.java @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.durabletask.implementation.models.OperationListResult; +import com.azure.resourcemanager.durabletask.models.ActionType; +import org.junit.jupiter.api.Assertions; + +public final class OperationListResultTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + OperationListResult model = BinaryData.fromString( + "{\"value\":[{\"name\":\"hq\",\"isDataAction\":true,\"display\":{\"provider\":\"pybczmehmtzopb\",\"resource\":\"h\",\"operation\":\"pidgsybbejhphoyc\",\"description\":\"xaobhdxbmtqioqjz\"},\"origin\":\"system\",\"actionType\":\"Internal\"},{\"name\":\"fpownoizhwlr\",\"isDataAction\":false,\"display\":{\"provider\":\"oqijgkdmbpaz\",\"resource\":\"bc\",\"operation\":\"pdznrbtcqqjnqgl\",\"description\":\"gnufoooj\"},\"origin\":\"system\",\"actionType\":\"Internal\"},{\"name\":\"esaagdfm\",\"isDataAction\":true,\"display\":{\"provider\":\"j\",\"resource\":\"ifkwmrvktsizntoc\",\"operation\":\"a\",\"description\":\"ajpsquc\"},\"origin\":\"system\",\"actionType\":\"Internal\"}],\"nextLink\":\"kfo\"}") + .toObject(OperationListResult.class); + Assertions.assertEquals(ActionType.INTERNAL, model.value().get(0).actionType()); + Assertions.assertEquals("kfo", model.nextLink()); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/OperationsListMockTests.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/OperationsListMockTests.java new file mode 100644 index 0000000000000..533759262944e --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/OperationsListMockTests.java @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.durabletask.DurableTaskManager; +import com.azure.resourcemanager.durabletask.models.ActionType; +import com.azure.resourcemanager.durabletask.models.Operation; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class OperationsListMockTests { + @Test + public void testList() throws Exception { + String responseStr + = "{\"value\":[{\"name\":\"wgcu\",\"isDataAction\":true,\"display\":{\"provider\":\"kdosvqw\",\"resource\":\"mdgbbjfdd\",\"operation\":\"bmbexppbhtqqro\",\"description\":\"p\"},\"origin\":\"user,system\",\"actionType\":\"Internal\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + DurableTaskManager manager = DurableTaskManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureEnvironment.AZURE)); + + PagedIterable response = manager.operations().list(com.azure.core.util.Context.NONE); + + Assertions.assertEquals(ActionType.INTERNAL, response.iterator().next().actionType()); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulerInnerTests.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulerInnerTests.java new file mode 100644 index 0000000000000..a796a1804856d --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulerInnerTests.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.durabletask.fluent.models.SchedulerInner; +import com.azure.resourcemanager.durabletask.models.SchedulerProperties; +import com.azure.resourcemanager.durabletask.models.SchedulerSku; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class SchedulerInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SchedulerInner model = BinaryData.fromString( + "{\"properties\":{\"provisioningState\":\"Succeeded\",\"endpoint\":\"pzvgnwzsymglzufc\",\"ipAllowlist\":[\"kohdbiha\"],\"sku\":{\"name\":\"ufhfcbjysa\",\"capacity\":437058664,\"redundancyState\":\"None\"}},\"location\":\"hab\",\"tags\":{\"byscnp\":\"ikxwc\",\"hiv\":\"x\",\"rtfw\":\"qniwbybrkxvdumj\",\"cs\":\"ukxgaud\"},\"id\":\"h\",\"name\":\"jcny\",\"type\":\"j\"}") + .toObject(SchedulerInner.class); + Assertions.assertEquals("hab", model.location()); + Assertions.assertEquals("ikxwc", model.tags().get("byscnp")); + Assertions.assertEquals("kohdbiha", model.properties().ipAllowlist().get(0)); + Assertions.assertEquals("ufhfcbjysa", model.properties().sku().name()); + Assertions.assertEquals(437058664, model.properties().sku().capacity()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + SchedulerInner model = new SchedulerInner().withLocation("hab") + .withTags(mapOf("byscnp", "ikxwc", "hiv", "x", "rtfw", "qniwbybrkxvdumj", "cs", "ukxgaud")) + .withProperties(new SchedulerProperties().withIpAllowlist(Arrays.asList("kohdbiha")) + .withSku(new SchedulerSku().withName("ufhfcbjysa").withCapacity(437058664))); + model = BinaryData.fromObject(model).toObject(SchedulerInner.class); + Assertions.assertEquals("hab", model.location()); + Assertions.assertEquals("ikxwc", model.tags().get("byscnp")); + Assertions.assertEquals("kohdbiha", model.properties().ipAllowlist().get(0)); + Assertions.assertEquals("ufhfcbjysa", model.properties().sku().name()); + Assertions.assertEquals(437058664, model.properties().sku().capacity()); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulerListResultTests.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulerListResultTests.java new file mode 100644 index 0000000000000..a2666921fe2d0 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulerListResultTests.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.durabletask.implementation.models.SchedulerListResult; +import org.junit.jupiter.api.Assertions; + +public final class SchedulerListResultTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SchedulerListResult model = BinaryData.fromString( + "{\"value\":[{\"properties\":{\"provisioningState\":\"Provisioning\",\"endpoint\":\"cmdv\",\"ipAllowlist\":[\"hulsuuvmkjozkrwf\",\"dio\",\"jpslwejd\"],\"sku\":{\"name\":\"vwryoqpso\",\"capacity\":2018987029,\"redundancyState\":\"None\"}},\"location\":\"akl\",\"tags\":{\"paojakhmsbzjh\":\"hbcryffdfdosyge\"},\"id\":\"rzevdphlxaol\",\"name\":\"hqtrgqjbpf\",\"type\":\"fsinzgvfcjrwzoxx\"},{\"properties\":{\"provisioningState\":\"Failed\",\"endpoint\":\"luwfzitonpeqfpjk\",\"ipAllowlist\":[\"xofpdvhpfxxypi\",\"i\",\"mayhuybbkpodepoo\",\"inuvamiheogn\"],\"sku\":{\"name\":\"rxzxtheo\",\"capacity\":372211152,\"redundancyState\":\"Zone\"}},\"location\":\"evcciqihnhun\",\"tags\":{\"gxg\":\"jzrnf\",\"fublj\":\"spemvtzfk\",\"aeqjhqjbasvms\":\"fxqeof\",\"gsntnbybkzgcwr\":\"jqul\"},\"id\":\"clxxwrljdo\",\"name\":\"skcqvkocrcjd\",\"type\":\"wtnhxbnjbiksqr\"}],\"nextLink\":\"ssainqpjwnzll\"}") + .toObject(SchedulerListResult.class); + Assertions.assertEquals("akl", model.value().get(0).location()); + Assertions.assertEquals("hbcryffdfdosyge", model.value().get(0).tags().get("paojakhmsbzjh")); + Assertions.assertEquals("hulsuuvmkjozkrwf", model.value().get(0).properties().ipAllowlist().get(0)); + Assertions.assertEquals("vwryoqpso", model.value().get(0).properties().sku().name()); + Assertions.assertEquals(2018987029, model.value().get(0).properties().sku().capacity()); + Assertions.assertEquals("ssainqpjwnzll", model.nextLink()); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulerPropertiesTests.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulerPropertiesTests.java new file mode 100644 index 0000000000000..c499f979e87fc --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulerPropertiesTests.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.durabletask.models.SchedulerProperties; +import com.azure.resourcemanager.durabletask.models.SchedulerSku; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class SchedulerPropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SchedulerProperties model = BinaryData.fromString( + "{\"provisioningState\":\"Accepted\",\"endpoint\":\"htnapczwlokjyem\",\"ipAllowlist\":[\"vnipjox\",\"jnchgej\",\"podmailzydehojwy\"],\"sku\":{\"name\":\"huxinpmqnj\",\"capacity\":956745772,\"redundancyState\":\"None\"}}") + .toObject(SchedulerProperties.class); + Assertions.assertEquals("vnipjox", model.ipAllowlist().get(0)); + Assertions.assertEquals("huxinpmqnj", model.sku().name()); + Assertions.assertEquals(956745772, model.sku().capacity()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + SchedulerProperties model + = new SchedulerProperties().withIpAllowlist(Arrays.asList("vnipjox", "jnchgej", "podmailzydehojwy")) + .withSku(new SchedulerSku().withName("huxinpmqnj").withCapacity(956745772)); + model = BinaryData.fromObject(model).toObject(SchedulerProperties.class); + Assertions.assertEquals("vnipjox", model.ipAllowlist().get(0)); + Assertions.assertEquals("huxinpmqnj", model.sku().name()); + Assertions.assertEquals(956745772, model.sku().capacity()); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulerSkuTests.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulerSkuTests.java new file mode 100644 index 0000000000000..e0240eb233747 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulerSkuTests.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.durabletask.models.SchedulerSku; +import org.junit.jupiter.api.Assertions; + +public final class SchedulerSkuTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SchedulerSku model + = BinaryData.fromString("{\"name\":\"jsprozvcpute\",\"capacity\":890104611,\"redundancyState\":\"Zone\"}") + .toObject(SchedulerSku.class); + Assertions.assertEquals("jsprozvcpute", model.name()); + Assertions.assertEquals(890104611, model.capacity()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + SchedulerSku model = new SchedulerSku().withName("jsprozvcpute").withCapacity(890104611); + model = BinaryData.fromObject(model).toObject(SchedulerSku.class); + Assertions.assertEquals("jsprozvcpute", model.name()); + Assertions.assertEquals(890104611, model.capacity()); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulersCreateOrUpdateMockTests.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulersCreateOrUpdateMockTests.java new file mode 100644 index 0000000000000..01993a79b3f6f --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulersCreateOrUpdateMockTests.java @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.durabletask.DurableTaskManager; +import com.azure.resourcemanager.durabletask.models.Scheduler; +import com.azure.resourcemanager.durabletask.models.SchedulerProperties; +import com.azure.resourcemanager.durabletask.models.SchedulerSku; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SchedulersCreateOrUpdateMockTests { + @Test + public void testCreateOrUpdate() throws Exception { + String responseStr + = "{\"properties\":{\"provisioningState\":\"Succeeded\",\"endpoint\":\"thz\",\"ipAllowlist\":[\"qdrabhjybigehoqf\",\"owskanyktz\"],\"sku\":{\"name\":\"cuiywgqyw\",\"capacity\":1211142115,\"redundancyState\":\"Zone\"}},\"location\":\"nhzgpphrcgyn\",\"tags\":{\"vmmcoofs\":\"pec\",\"y\":\"lzevgbmqjqab\",\"wnfnbacf\":\"mivkwlzuvcc\",\"bqqwxrj\":\"onlebxetqgtzxdpn\"},\"id\":\"eallnwsubisnj\",\"name\":\"mpmngnzscxaqwoo\",\"type\":\"hcbonqvpkvlr\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + DurableTaskManager manager = DurableTaskManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureEnvironment.AZURE)); + + Scheduler response = manager.schedulers() + .define("c") + .withRegion("ntwndeicbtwnpzao") + .withExistingResourceGroup("ukdkexxppofmxa") + .withTags(mapOf("qkwpyeicxmqc", "hrhcffcyddglmjth", "pbobjo", "wqvhkhixuigdt", "w", "hm", "a", "a")) + .withProperties(new SchedulerProperties().withIpAllowlist(Arrays.asList("hvpmoue", "hd")) + .withSku(new SchedulerSku().withName("xibqeojnx").withCapacity(2010157167))) + .create(); + + Assertions.assertEquals("nhzgpphrcgyn", response.location()); + Assertions.assertEquals("pec", response.tags().get("vmmcoofs")); + Assertions.assertEquals("qdrabhjybigehoqf", response.properties().ipAllowlist().get(0)); + Assertions.assertEquals("cuiywgqyw", response.properties().sku().name()); + Assertions.assertEquals(1211142115, response.properties().sku().capacity()); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulersGetByResourceGroupWithResponseMockTests.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulersGetByResourceGroupWithResponseMockTests.java new file mode 100644 index 0000000000000..2e6e9aa5e757d --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulersGetByResourceGroupWithResponseMockTests.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.durabletask.DurableTaskManager; +import com.azure.resourcemanager.durabletask.models.Scheduler; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SchedulersGetByResourceGroupWithResponseMockTests { + @Test + public void testGetByResourceGroupWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"provisioningState\":\"Updating\",\"endpoint\":\"kujysvlejuvfq\",\"ipAllowlist\":[\"rlyxwjkcprbnw\",\"xgjvtbv\",\"ysszdnrujqguh\"],\"sku\":{\"name\":\"uouq\",\"capacity\":1853724475,\"redundancyState\":\"None\"}},\"location\":\"bngui\",\"tags\":{\"x\":\"uizga\"},\"id\":\"fizuckyf\",\"name\":\"hr\",\"type\":\"idf\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + DurableTaskManager manager = DurableTaskManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureEnvironment.AZURE)); + + Scheduler response = manager.schedulers() + .getByResourceGroupWithResponse("gbquxigj", "jgzjaoyfhrtx", com.azure.core.util.Context.NONE) + .getValue(); + + Assertions.assertEquals("bngui", response.location()); + Assertions.assertEquals("uizga", response.tags().get("x")); + Assertions.assertEquals("rlyxwjkcprbnw", response.properties().ipAllowlist().get(0)); + Assertions.assertEquals("uouq", response.properties().sku().name()); + Assertions.assertEquals(1853724475, response.properties().sku().capacity()); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulersListByResourceGroupMockTests.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulersListByResourceGroupMockTests.java new file mode 100644 index 0000000000000..3f3d355cb04c1 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulersListByResourceGroupMockTests.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.durabletask.DurableTaskManager; +import com.azure.resourcemanager.durabletask.models.Scheduler; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SchedulersListByResourceGroupMockTests { + @Test + public void testListByResourceGroup() throws Exception { + String responseStr + = "{\"value\":[{\"properties\":{\"provisioningState\":\"Canceled\",\"endpoint\":\"sdkf\",\"ipAllowlist\":[\"wxmnteiwao\",\"vkmijcmmxdcuf\",\"fsrpymzidnse\"],\"sku\":{\"name\":\"cxtbzsg\",\"capacity\":121296393,\"redundancyState\":\"None\"}},\"location\":\"ewmdw\",\"tags\":{\"sflnrosfqp\":\"iachbo\",\"zvypyqrimzinp\":\"eeh\",\"dqxhcrmnohjtckwh\":\"swjdkirso\",\"gr\":\"soifiyipjxsqw\"},\"id\":\"bznorcjxvsnby\",\"name\":\"qabnmoc\",\"type\":\"cyshurzafbljjgp\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + DurableTaskManager manager = DurableTaskManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureEnvironment.AZURE)); + + PagedIterable response + = manager.schedulers().listByResourceGroup("zwdzuh", com.azure.core.util.Context.NONE); + + Assertions.assertEquals("ewmdw", response.iterator().next().location()); + Assertions.assertEquals("iachbo", response.iterator().next().tags().get("sflnrosfqp")); + Assertions.assertEquals("wxmnteiwao", response.iterator().next().properties().ipAllowlist().get(0)); + Assertions.assertEquals("cxtbzsg", response.iterator().next().properties().sku().name()); + Assertions.assertEquals(121296393, response.iterator().next().properties().sku().capacity()); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulersListMockTests.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulersListMockTests.java new file mode 100644 index 0000000000000..17844cf17e737 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/SchedulersListMockTests.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.durabletask.DurableTaskManager; +import com.azure.resourcemanager.durabletask.models.Scheduler; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SchedulersListMockTests { + @Test + public void testList() throws Exception { + String responseStr + = "{\"value\":[{\"properties\":{\"provisioningState\":\"Failed\",\"endpoint\":\"jmkljavbqidtqajz\",\"ipAllowlist\":[\"l\",\"kudjkrlkhb\",\"hfepgzgqex\"],\"sku\":{\"name\":\"locx\",\"capacity\":1399091517,\"redundancyState\":\"Zone\"}},\"location\":\"rhhbcs\",\"tags\":{\"bnbdxkqpxokajion\":\"mmajtjaodx\",\"jrmvdjwzrlo\":\"imexgstxgcpodgma\",\"hijco\":\"mcl\"},\"id\":\"jctbza\",\"name\":\"s\",\"type\":\"sycbkbfk\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + DurableTaskManager manager = DurableTaskManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureEnvironment.AZURE)); + + PagedIterable response = manager.schedulers().list(com.azure.core.util.Context.NONE); + + Assertions.assertEquals("rhhbcs", response.iterator().next().location()); + Assertions.assertEquals("mmajtjaodx", response.iterator().next().tags().get("bnbdxkqpxokajion")); + Assertions.assertEquals("l", response.iterator().next().properties().ipAllowlist().get(0)); + Assertions.assertEquals("locx", response.iterator().next().properties().sku().name()); + Assertions.assertEquals(1399091517, response.iterator().next().properties().sku().capacity()); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubInnerTests.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubInnerTests.java new file mode 100644 index 0000000000000..527fc48b751f3 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubInnerTests.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.durabletask.fluent.models.TaskHubInner; +import com.azure.resourcemanager.durabletask.models.TaskHubProperties; + +public final class TaskHubInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + TaskHubInner model = BinaryData.fromString( + "{\"properties\":{\"provisioningState\":\"Provisioning\",\"dashboardUrl\":\"eebvmgxsab\"},\"id\":\"qduujitcjczdz\",\"name\":\"vndhkrwpdapp\",\"type\":\"sbdkvwr\"}") + .toObject(TaskHubInner.class); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + TaskHubInner model = new TaskHubInner().withProperties(new TaskHubProperties()); + model = BinaryData.fromObject(model).toObject(TaskHubInner.class); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubListResultTests.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubListResultTests.java new file mode 100644 index 0000000000000..3cc722d491c10 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubListResultTests.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.durabletask.implementation.models.TaskHubListResult; +import org.junit.jupiter.api.Assertions; + +public final class TaskHubListResultTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + TaskHubListResult model = BinaryData.fromString( + "{\"value\":[{\"properties\":{\"provisioningState\":\"Deleting\",\"dashboardUrl\":\"hugjzzdatqxhoc\"},\"id\":\"eablg\",\"name\":\"huticndvkao\",\"type\":\"wyiftyhxhur\"},{\"properties\":{\"provisioningState\":\"Updating\",\"dashboardUrl\":\"xolniwpwcukjfk\"},\"id\":\"awxklr\",\"name\":\"plwckbas\",\"type\":\"ypnddhsgcb\"},{\"properties\":{\"provisioningState\":\"Provisioning\",\"dashboardUrl\":\"jkot\"},\"id\":\"qgoulznd\",\"name\":\"i\",\"type\":\"wyqkgfgibm\"},{\"properties\":{\"provisioningState\":\"Failed\",\"dashboardUrl\":\"eqsrxybzqqedqyt\"},\"id\":\"iqfouflmmnkz\",\"name\":\"modmglougpb\",\"type\":\"wtmutduq\"}],\"nextLink\":\"ap\"}") + .toObject(TaskHubListResult.class); + Assertions.assertEquals("ap", model.nextLink()); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubPropertiesTests.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubPropertiesTests.java new file mode 100644 index 0000000000000..da42e7f7713d4 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubPropertiesTests.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.durabletask.models.TaskHubProperties; + +public final class TaskHubPropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + TaskHubProperties model + = BinaryData.fromString("{\"provisioningState\":\"Provisioning\",\"dashboardUrl\":\"usnhutje\"}") + .toObject(TaskHubProperties.class); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + TaskHubProperties model = new TaskHubProperties(); + model = BinaryData.fromObject(model).toObject(TaskHubProperties.class); + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubsCreateOrUpdateMockTests.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubsCreateOrUpdateMockTests.java new file mode 100644 index 0000000000000..bd9155c3bb87d --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubsCreateOrUpdateMockTests.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.durabletask.DurableTaskManager; +import com.azure.resourcemanager.durabletask.models.TaskHub; +import com.azure.resourcemanager.durabletask.models.TaskHubProperties; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class TaskHubsCreateOrUpdateMockTests { + @Test + public void testCreateOrUpdate() throws Exception { + String responseStr + = "{\"properties\":{\"provisioningState\":\"Succeeded\",\"dashboardUrl\":\"cj\"},\"id\":\"pvhez\",\"name\":\"kgqhcjrefovg\",\"type\":\"kqsleyyvxy\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + DurableTaskManager manager = DurableTaskManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureEnvironment.AZURE)); + + TaskHub response = manager.taskHubs() + .define("yggdtjixh") + .withExistingScheduler("wdkcglhsl", "zj") + .withProperties(new TaskHubProperties()) + .create(); + + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubsGetWithResponseMockTests.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubsGetWithResponseMockTests.java new file mode 100644 index 0000000000000..5f3a9328727d8 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubsGetWithResponseMockTests.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.durabletask.DurableTaskManager; +import com.azure.resourcemanager.durabletask.models.TaskHub; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class TaskHubsGetWithResponseMockTests { + @Test + public void testGetWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"provisioningState\":\"Canceled\",\"dashboardUrl\":\"masxazjpqyegu\"},\"id\":\"hb\",\"name\":\"xhejjzzvdud\",\"type\":\"wdslfhotwmcy\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + DurableTaskManager manager = DurableTaskManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureEnvironment.AZURE)); + + TaskHub response = manager.taskHubs() + .getWithResponse("njeaseipheofloke", "y", "enjbdlwtgrhp", com.azure.core.util.Context.NONE) + .getValue(); + + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubsListBySchedulerMockTests.java b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubsListBySchedulerMockTests.java new file mode 100644 index 0000000000000..22ee60aaa5e85 --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/src/test/java/com/azure/resourcemanager/durabletask/generated/TaskHubsListBySchedulerMockTests.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.durabletask.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.durabletask.DurableTaskManager; +import com.azure.resourcemanager.durabletask.models.TaskHub; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class TaskHubsListBySchedulerMockTests { + @Test + public void testListByScheduler() throws Exception { + String responseStr + = "{\"value\":[{\"properties\":{\"provisioningState\":\"Deleting\",\"dashboardUrl\":\"fsoppusuesnzw\"},\"id\":\"jbavorxzdm\",\"name\":\"hctbqvudwxdn\",\"type\":\"nvowgujju\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + DurableTaskManager manager = DurableTaskManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureEnvironment.AZURE)); + + PagedIterable response + = manager.taskHubs().listByScheduler("pwlbjnpg", "cftadeh", com.azure.core.util.Context.NONE); + + } +} diff --git a/sdk/durabletask/azure-resourcemanager-durabletask/tsp-location.yaml b/sdk/durabletask/azure-resourcemanager-durabletask/tsp-location.yaml new file mode 100644 index 0000000000000..5560f71e70fcf --- /dev/null +++ b/sdk/durabletask/azure-resourcemanager-durabletask/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/durabletask/DurableTask.Management +commit: efff70bcf4dd190290ddd693d5023c76949bc6c0 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/durabletask/ci.yml b/sdk/durabletask/ci.yml new file mode 100644 index 0000000000000..5c1b8f798bdaf --- /dev/null +++ b/sdk/durabletask/ci.yml @@ -0,0 +1,46 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/durabletask/ci.yml + - sdk/durabletask/azure-resourcemanager-durabletask/ + exclude: + - sdk/durabletask/pom.xml + - sdk/durabletask/azure-resourcemanager-durabletask/pom.xml + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/durabletask/ci.yml + - sdk/durabletask/azure-resourcemanager-durabletask/ + exclude: + - sdk/durabletask/pom.xml + - sdk/durabletask/azure-resourcemanager-durabletask/pom.xml + +parameters: + - name: release_azureresourcemanagerdurabletask + displayName: azure-resourcemanager-durabletask + type: boolean + default: false + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: durabletask + Artifacts: + - name: azure-resourcemanager-durabletask + groupId: com.azure.resourcemanager + safeName: azureresourcemanagerdurabletask + releaseInBatch: ${{ parameters.release_azureresourcemanagerdurabletask }} diff --git a/sdk/durabletask/pom.xml b/sdk/durabletask/pom.xml new file mode 100644 index 0000000000000..cd9bc240b1e92 --- /dev/null +++ b/sdk/durabletask/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + com.azure + azure-durabletask-service + pom + 1.0.0 + + + azure-resourcemanager-durabletask + +