From e01da2413799f75ad0c6b0f810696a2a06a1bc5c Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 25 Nov 2021 06:36:26 +0000 Subject: [PATCH] CodeGen from PR 16831 in Azure/azure-rest-api-specs Merge 9f2cecaee84483ce0c76394f496f4ee0cbb8cc33 into b6b834584cb58a3c2cbe887570fa0942b397dfc7 --- eng/versioning/version_client.txt | 1 + pom.xml | 1 + .../CHANGELOG.md | 5 + .../README.md | 102 ++ .../SAMPLE.md | 197 +++ .../pom.xml | 81 + .../loadtestservice/LoadTestManager.java | 254 +++ .../fluent/LoadTestClient.java | 60 + .../fluent/LoadTestsClient.java | 212 +++ .../fluent/OperationsClient.java | 36 + .../fluent/models/LoadTestProperties.java | 81 + .../fluent/models/LoadTestResourceInner.java | 130 ++ .../fluent/models/OperationInner.java | 125 ++ .../fluent/models/package-info.java | 9 + .../loadtestservice/fluent/package-info.java | 9 + .../implementation/LoadTestClientBuilder.java | 146 ++ .../implementation/LoadTestClientImpl.java | 307 ++++ .../implementation/LoadTestResourceImpl.java | 215 +++ .../implementation/LoadTestsClientImpl.java | 1361 +++++++++++++++++ .../implementation/LoadTestsImpl.java | 171 +++ .../implementation/OperationImpl.java | 51 + .../implementation/OperationsClientImpl.java | 269 ++++ .../implementation/OperationsImpl.java | 46 + .../loadtestservice/implementation/Utils.java | 204 +++ .../implementation/package-info.java | 9 + .../loadtestservice/models/ActionType.java | 31 + .../models/LoadTestResource.java | 261 ++++ .../models/LoadTestResourcePageList.java | 81 + .../LoadTestResourcePatchRequestBody.java | 108 ++ ...estResourcePatchRequestBodyProperties.java | 50 + .../loadtestservice/models/LoadTests.java | 156 ++ .../loadtestservice/models/Operation.java | 56 + .../models/OperationDisplay.java | 93 ++ .../models/OperationListResult.java | 62 + .../loadtestservice/models/Operations.java | 31 + .../loadtestservice/models/Origin.java | 37 + .../loadtestservice/models/ResourceState.java | 40 + .../models/SystemAssignedServiceIdentity.java | 91 ++ .../SystemAssignedServiceIdentityType.java | 34 + .../loadtestservice/models/package-info.java | 9 + .../loadtestservice/package-info.java | 9 + .../src/main/java/module-info.java | 19 + .../LoadTestsCreateOrUpdateSamples.java | 41 + .../generated/LoadTestsDeleteSamples.java | 22 + .../LoadTestsGetByResourceGroupSamples.java | 22 + .../LoadTestsListByResourceGroupSamples.java | 22 + .../generated/LoadTestsListSamples.java | 22 + .../generated/LoadTestsUpdateSamples.java | 38 + .../generated/OperationsListSamples.java | 22 + sdk/loadtestservice/ci.yml | 39 + sdk/loadtestservice/pom.xml | 53 + 51 files changed, 5531 insertions(+) create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/CHANGELOG.md create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/README.md create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/SAMPLE.md create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/pom.xml create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/LoadTestManager.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/LoadTestClient.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/LoadTestsClient.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/OperationsClient.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/models/LoadTestProperties.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/models/LoadTestResourceInner.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/models/OperationInner.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/models/package-info.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/package-info.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/LoadTestClientBuilder.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/LoadTestClientImpl.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/LoadTestResourceImpl.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/LoadTestsClientImpl.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/LoadTestsImpl.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/OperationImpl.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/OperationsClientImpl.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/OperationsImpl.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/Utils.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/package-info.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/ActionType.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/LoadTestResource.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/LoadTestResourcePageList.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/LoadTestResourcePatchRequestBody.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/LoadTestResourcePatchRequestBodyProperties.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/LoadTests.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/Operation.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/OperationDisplay.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/OperationListResult.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/Operations.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/Origin.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/ResourceState.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/SystemAssignedServiceIdentity.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/SystemAssignedServiceIdentityType.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/package-info.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/package-info.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/module-info.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsCreateOrUpdateSamples.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsDeleteSamples.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsGetByResourceGroupSamples.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsListByResourceGroupSamples.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsListSamples.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsUpdateSamples.java create mode 100644 sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/OperationsListSamples.java create mode 100644 sdk/loadtestservice/ci.yml create mode 100644 sdk/loadtestservice/pom.xml diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index c3219c3a3cc7..16cd55481a9a 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -323,6 +323,7 @@ com.azure.resourcemanager:azure-resourcemanager-logz;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-storagepool;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-dataprotection;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-desktopvirtualization;1.0.0-beta.1;1.0.0-beta.2 +com.azure.resourcemanager:azure-resourcemanager-loadtestservice;1.0.0-beta.1;1.0.0-beta.1 com.azure.tools:azure-sdk-archetype;1.0.0;1.0.0 # Unreleased dependencies: Copy the entry from above, prepend "unreleased_" and remove the current diff --git a/pom.xml b/pom.xml index b306ab55b97d..24520d515aae 100644 --- a/pom.xml +++ b/pom.xml @@ -781,6 +781,7 @@ sdk/kubernetesconfiguration sdk/kusto sdk/labservices + sdk/loadtestservice sdk/loganalytics sdk/logic sdk/logz diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/CHANGELOG.md b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/CHANGELOG.md new file mode 100644 index 000000000000..245ede4387ef --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0-beta.1 (2021-11-25) + +- Azure Resource Manager LoadTest client library for Java. This package contains Microsoft Azure SDK for LoadTest Management SDK. LoadTest client provides access to LoadTest Resource and it's status operations. Package tag package-2021-12-01-preview. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/README.md b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/README.md new file mode 100644 index 000000000000..4874e925ba73 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/README.md @@ -0,0 +1,102 @@ +# Azure Resource Manager LoadTest client library for Java + +Azure Resource Manager LoadTest client library for Java. + +This package contains Microsoft Azure SDK for LoadTest Management SDK. LoadTest client provides access to LoadTest Resource and it's status operations. Package tag package-2021-12-01-preview. 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-loadtestservice;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-loadtestservice + 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] package and [Azure Core Netty HTTP][azure_core_http_netty] package provide the default implementation. + +### Authentication + +By default, Azure Active Directory token authentication depends on correct configure of following environment variables. + +- `AZURE_CLIENT_ID` for Azure client ID. +- `AZURE_TENANT_ID` for Azure tenant ID. +- `AZURE_CLIENT_SECRET` or `AZURE_CLIENT_CERTIFICATE_PATH` for client secret or client certificate. + +In addition, Azure subscription ID can be configured via environment variable `AZURE_SUBSCRIPTION_ID`. + +With above configuration, `azure` client can be authenticated by following code: + +```java +AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE); +TokenCredential credential = new DefaultAzureCredentialBuilder() + .authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint()) + .build(); +LoadTestManager manager = LoadTestManager + .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/loadtestservice/azure-resourcemanager-loadtestservice/SAMPLE.md) + + +## Troubleshooting + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md). + +1. Fork it +1. Create your feature branch (`git checkout -b my-new-feature`) +1. Commit your changes (`git commit -am 'Add some feature'`) +1. Push to the branch (`git push origin my-new-feature`) +1. Create new Pull Request + + +[survey]: https://microsoft.qualtrics.com/jfe/form/SV_ehN0lIk2FKEBkwd?Q_CHL=DOCS +[docs]: https://azure.github.io/azure-sdk-for-java/ +[jdk]: https://docs.microsoft.com/java/azure/jdk/ +[azure_subscription]: https://azure.microsoft.com/free/ +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity +[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 diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/SAMPLE.md b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/SAMPLE.md new file mode 100644 index 000000000000..4d584fc7d749 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/SAMPLE.md @@ -0,0 +1,197 @@ +# Code snippets and samples + + +## LoadTests + +- [CreateOrUpdate](#loadtests_createorupdate) +- [Delete](#loadtests_delete) +- [GetByResourceGroup](#loadtests_getbyresourcegroup) +- [List](#loadtests_list) +- [ListByResourceGroup](#loadtests_listbyresourcegroup) +- [Update](#loadtests_update) + +## Operations + +- [List](#operations_list) +### LoadTests_CreateOrUpdate + +```java +import java.util.HashMap; +import java.util.Map; + +/** Samples for LoadTests CreateOrUpdate. */ +public final class LoadTestsCreateOrUpdateSamples { + /* + * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_CreateOrUpdate.json + */ + /** + * Sample code: LoadTests_CreateOrUpdate. + * + * @param manager Entry point to LoadTestManager. + */ + public static void loadTestsCreateOrUpdate(com.azure.resourcemanager.loadtestservice.LoadTestManager manager) { + manager + .loadTests() + .define("myLoadTest") + .withRegion("westus") + .withExistingResourceGroup("dummyrg") + .withTags(mapOf("Team", "Dev Exp")) + .withDescription("This is new load test resource") + .create(); + } + + @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; + } +} +``` + +### LoadTests_Delete + +```java +import com.azure.core.util.Context; + +/** Samples for LoadTests Delete. */ +public final class LoadTestsDeleteSamples { + /* + * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_Delete.json + */ + /** + * Sample code: LoadTests_Delete. + * + * @param manager Entry point to LoadTestManager. + */ + public static void loadTestsDelete(com.azure.resourcemanager.loadtestservice.LoadTestManager manager) { + manager.loadTests().delete("dummyrg", "myLoadTest", Context.NONE); + } +} +``` + +### LoadTests_GetByResourceGroup + +```java +import com.azure.core.util.Context; + +/** Samples for LoadTests GetByResourceGroup. */ +public final class LoadTestsGetByResourceGroupSamples { + /* + * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_Get.json + */ + /** + * Sample code: LoadTests_Get. + * + * @param manager Entry point to LoadTestManager. + */ + public static void loadTestsGet(com.azure.resourcemanager.loadtestservice.LoadTestManager manager) { + manager.loadTests().getByResourceGroupWithResponse("dummyrg", "myLoadTest", Context.NONE); + } +} +``` + +### LoadTests_List + +```java +import com.azure.core.util.Context; + +/** Samples for LoadTests List. */ +public final class LoadTestsListSamples { + /* + * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_ListBySubscription.json + */ + /** + * Sample code: LoadTests_ListBySubscription. + * + * @param manager Entry point to LoadTestManager. + */ + public static void loadTestsListBySubscription(com.azure.resourcemanager.loadtestservice.LoadTestManager manager) { + manager.loadTests().list(Context.NONE); + } +} +``` + +### LoadTests_ListByResourceGroup + +```java +import com.azure.core.util.Context; + +/** Samples for LoadTests ListByResourceGroup. */ +public final class LoadTestsListByResourceGroupSamples { + /* + * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_ListByResourceGroup.json + */ + /** + * Sample code: LoadTests_ListByResourceGroup. + * + * @param manager Entry point to LoadTestManager. + */ + public static void loadTestsListByResourceGroup(com.azure.resourcemanager.loadtestservice.LoadTestManager manager) { + manager.loadTests().listByResourceGroup("dummyrg", Context.NONE); + } +} +``` + +### LoadTests_Update + +```java +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.Context; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.loadtestservice.models.LoadTestResource; +import com.azure.resourcemanager.loadtestservice.models.LoadTestResourcePatchRequestBodyProperties; +import java.io.IOException; + +/** Samples for LoadTests Update. */ +public final class LoadTestsUpdateSamples { + /* + * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_Update.json + */ + /** + * Sample code: LoadTests_Update. + * + * @param manager Entry point to LoadTestManager. + */ + public static void loadTestsUpdate(com.azure.resourcemanager.loadtestservice.LoadTestManager manager) + throws IOException { + LoadTestResource resource = + manager.loadTests().getByResourceGroupWithResponse("dummyrg", "myLoadTest", Context.NONE).getValue(); + resource + .update() + .withTags( + SerializerFactory + .createDefaultManagementSerializerAdapter() + .deserialize("{\"Division\":\"LT\",\"Team\":\"Dev Exp\"}", Object.class, SerializerEncoding.JSON)) + .withProperties( + new LoadTestResourcePatchRequestBodyProperties().withDescription("This is new load test resource")) + .apply(); + } +} +``` + +### Operations_List + +```java +import com.azure.core.util.Context; + +/** Samples for Operations List. */ +public final class OperationsListSamples { + /* + * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/Operations_List.json + */ + /** + * Sample code: Operations_List. + * + * @param manager Entry point to LoadTestManager. + */ + public static void operationsList(com.azure.resourcemanager.loadtestservice.LoadTestManager manager) { + manager.operations().list(Context.NONE); + } +} +``` + diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/pom.xml b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/pom.xml new file mode 100644 index 000000000000..f114bdc9b562 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/pom.xml @@ -0,0 +1,81 @@ + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure.resourcemanager + azure-resourcemanager-loadtestservice + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for LoadTest Management + This package contains Microsoft Azure SDK for LoadTest Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. LoadTest client provides access to LoadTest Resource and it's status operations. Package tag package-2021-12-01-preview. + 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 + true + false + + + + + + com.azure + azure-core + 1.22.0 + + + com.azure + azure-core-management + 1.4.3 + + + + + + org.revapi + revapi-maven-plugin + 0.11.2 + + + + + java.method.addedToInterface + + + true + .* + com\.azure\.resourcemanager(\.[^.]+)+\.fluent(\.[^.]+)* + + + + + + + + diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/LoadTestManager.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/LoadTestManager.java new file mode 100644 index 000000000000..c1038688ceb4 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/LoadTestManager.java @@ -0,0 +1,254 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice; + +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.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.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.loadtestservice.fluent.LoadTestClient; +import com.azure.resourcemanager.loadtestservice.implementation.LoadTestClientBuilder; +import com.azure.resourcemanager.loadtestservice.implementation.LoadTestsImpl; +import com.azure.resourcemanager.loadtestservice.implementation.OperationsImpl; +import com.azure.resourcemanager.loadtestservice.models.LoadTests; +import com.azure.resourcemanager.loadtestservice.models.Operations; +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 LoadTestManager. LoadTest client provides access to LoadTest Resource and it's status operations. */ +public final class LoadTestManager { + private Operations operations; + + private LoadTests loadTests; + + private final LoadTestClient clientObject; + + private LoadTestManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = + new LoadTestClientBuilder() + .pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of LoadTest service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the LoadTest service API instance. + */ + public static LoadTestManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return configure().authenticate(credential, profile); + } + + /** + * Gets a Configurable instance that can be used to create LoadTestManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new LoadTestManager.Configurable(); + } + + /** The Configurable allowing configurations to be set. */ + public static final class Configurable { + private 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 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 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, "'retryPolicy' cannot be null."); + if (this.defaultPollInterval.isNegative()) { + throw logger.logExceptionAsError(new IllegalArgumentException("'httpPipeline' cannot be negative")); + } + return this; + } + + /** + * Creates an instance of LoadTest service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the LoadTest service API instance. + */ + public LoadTestManager 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.loadtestservice") + .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) { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + 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 LoadTestManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** @return Resource collection API of Operations. */ + public Operations operations() { + if (this.operations == null) { + this.operations = new OperationsImpl(clientObject.getOperations(), this); + } + return operations; + } + + /** @return Resource collection API of LoadTests. */ + public LoadTests loadTests() { + if (this.loadTests == null) { + this.loadTests = new LoadTestsImpl(clientObject.getLoadTests(), this); + } + return loadTests; + } + + /** + * @return Wrapped service client LoadTestClient providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + */ + public LoadTestClient serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/LoadTestClient.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/LoadTestClient.java new file mode 100644 index 000000000000..3dafb2d2e280 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/LoadTestClient.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** The interface for LoadTestClient class. */ +public interface LoadTestClient { + /** + * Gets The ID of the target subscription. + * + * @return the subscriptionId value. + */ + String getSubscriptionId(); + + /** + * Gets server parameter. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Api Version. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * 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 LoadTestsClient object to access its operations. + * + * @return the LoadTestsClient object. + */ + LoadTestsClient getLoadTests(); +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/LoadTestsClient.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/LoadTestsClient.java new file mode 100644 index 000000000000..616734d39e53 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/LoadTestsClient.java @@ -0,0 +1,212 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.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.loadtestservice.fluent.models.LoadTestResourceInner; +import com.azure.resourcemanager.loadtestservice.models.LoadTestResourcePatchRequestBody; + +/** An instance of this class provides access to all the operations defined in LoadTestsClient. */ +public interface LoadTestsClient { + /** + * Lists loadtests resources in a 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 list of resources page result. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * Lists loadtests resources in a 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 list of resources page result. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); + + /** + * Lists loadtest resources in a 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 list of resources page result. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * Lists loadtest resources in a 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 list of resources page result. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Get a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 LoadTest resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + LoadTestResourceInner getByResourceGroup(String resourceGroupName, String loadTestName); + + /** + * Get a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 LoadTest resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse( + String resourceGroupName, String loadTestName, Context context); + + /** + * Create or update LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param loadTestResource LoadTest resource data. + * @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 loadTest details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + LoadTestResourceInner createOrUpdate( + String resourceGroupName, String loadTestName, LoadTestResourceInner loadTestResource); + + /** + * Create or update LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param loadTestResource LoadTest resource data. + * @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 loadTest details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createOrUpdateWithResponse( + String resourceGroupName, String loadTestName, LoadTestResourceInner loadTestResource, Context context); + + /** + * Update a loadtest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param loadTestResourcePatchRequestBody LoadTest resource update data. + * @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 loadTest details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + LoadTestResourceInner update( + String resourceGroupName, + String loadTestName, + LoadTestResourcePatchRequestBody loadTestResourcePatchRequestBody); + + /** + * Update a loadtest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param loadTestResourcePatchRequestBody LoadTest resource update data. + * @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 loadTest details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response updateWithResponse( + String resourceGroupName, + String loadTestName, + LoadTestResourcePatchRequestBody loadTestResourcePatchRequestBody, + Context context); + + /** + * Delete a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 completion. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String loadTestName); + + /** + * Delete a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 completion. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String loadTestName, Context context); + + /** + * Delete a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 loadTestName); + + /** + * Delete a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 loadTestName, Context context); +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/OperationsClient.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/OperationsClient.java new file mode 100644 index 000000000000..ce89a27e2cc8 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/OperationsClient.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.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.loadtestservice.fluent.models.OperationInner; + +/** An instance of this class provides access to all the operations defined in OperationsClient. */ +public interface OperationsClient { + /** + * Lists all the available API operations for Load Test Resource. + * + * @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. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * Lists all the available API operations for Load Test Resource. + * + * @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. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/models/LoadTestProperties.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/models/LoadTestProperties.java new file mode 100644 index 000000000000..c52ca876ba4d --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/models/LoadTestProperties.java @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.loadtestservice.models.ResourceState; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** LoadTest resource properties. */ +@Fluent +public final class LoadTestProperties { + @JsonIgnore private final ClientLogger logger = new ClientLogger(LoadTestProperties.class); + + /* + * Description of the resource. + */ + @JsonProperty(value = "description") + private String description; + + /* + * Resource provisioning state. + */ + @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY) + private ResourceState provisioningState; + + /* + * Resource data plane URI. + */ + @JsonProperty(value = "dataPlaneURI", access = JsonProperty.Access.WRITE_ONLY) + private String dataPlaneUri; + + /** + * Get the description property: Description of the resource. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Set the description property: Description of the resource. + * + * @param description the description value to set. + * @return the LoadTestProperties object itself. + */ + public LoadTestProperties withDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the provisioningState property: Resource provisioning state. + * + * @return the provisioningState value. + */ + public ResourceState provisioningState() { + return this.provisioningState; + } + + /** + * Get the dataPlaneUri property: Resource data plane URI. + * + * @return the dataPlaneUri value. + */ + public String dataPlaneUri() { + return this.dataPlaneUri; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/models/LoadTestResourceInner.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/models/LoadTestResourceInner.java new file mode 100644 index 000000000000..2e5bbe43e01b --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/models/LoadTestResourceInner.java @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.loadtestservice.models.ResourceState; +import com.azure.resourcemanager.loadtestservice.models.SystemAssignedServiceIdentity; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + +/** LoadTest details. */ +@Fluent +public final class LoadTestResourceInner extends Resource { + @JsonIgnore private final ClientLogger logger = new ClientLogger(LoadTestResourceInner.class); + + /* + * Load Test resource properties + */ + @JsonProperty(value = "properties") + private LoadTestProperties innerProperties; + + /* + * The type of identity used for the resource. + */ + @JsonProperty(value = "identity") + private SystemAssignedServiceIdentity identity; + + /** + * Get the innerProperties property: Load Test resource properties. + * + * @return the innerProperties value. + */ + private LoadTestProperties innerProperties() { + return this.innerProperties; + } + + /** + * Get the identity property: The type of identity used for the resource. + * + * @return the identity value. + */ + public SystemAssignedServiceIdentity identity() { + return this.identity; + } + + /** + * Set the identity property: The type of identity used for the resource. + * + * @param identity the identity value to set. + * @return the LoadTestResourceInner object itself. + */ + public LoadTestResourceInner withIdentity(SystemAssignedServiceIdentity identity) { + this.identity = identity; + return this; + } + + /** {@inheritDoc} */ + @Override + public LoadTestResourceInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** {@inheritDoc} */ + @Override + public LoadTestResourceInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * Get the description property: Description of the resource. + * + * @return the description value. + */ + public String description() { + return this.innerProperties() == null ? null : this.innerProperties().description(); + } + + /** + * Set the description property: Description of the resource. + * + * @param description the description value to set. + * @return the LoadTestResourceInner object itself. + */ + public LoadTestResourceInner withDescription(String description) { + if (this.innerProperties() == null) { + this.innerProperties = new LoadTestProperties(); + } + this.innerProperties().withDescription(description); + return this; + } + + /** + * Get the provisioningState property: Resource provisioning state. + * + * @return the provisioningState value. + */ + public ResourceState provisioningState() { + return this.innerProperties() == null ? null : this.innerProperties().provisioningState(); + } + + /** + * Get the dataPlaneUri property: Resource data plane URI. + * + * @return the dataPlaneUri value. + */ + public String dataPlaneUri() { + return this.innerProperties() == null ? null : this.innerProperties().dataPlaneUri(); + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (innerProperties() != null) { + innerProperties().validate(); + } + if (identity() != null) { + identity().validate(); + } + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/models/OperationInner.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/models/OperationInner.java new file mode 100644 index 000000000000..8a2fd72fd6d3 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/models/OperationInner.java @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.loadtestservice.models.ActionType; +import com.azure.resourcemanager.loadtestservice.models.OperationDisplay; +import com.azure.resourcemanager.loadtestservice.models.Origin; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** REST API Operation Details of a REST API operation, returned from the Resource Provider Operations API. */ +@Fluent +public final class OperationInner { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationInner.class); + + /* + * The name of the operation, as per Resource-Based Access Control (RBAC). + * Examples: "Microsoft.Compute/virtualMachines/write", + * "Microsoft.Compute/virtualMachines/capture/action" + */ + @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /* + * Whether the operation applies to data-plane. This is "true" for + * data-plane operations and "false" for ARM/control-plane operations. + */ + @JsonProperty(value = "isDataAction", access = JsonProperty.Access.WRITE_ONLY) + private Boolean isDataAction; + + /* + * Localized display information for this particular operation. + */ + @JsonProperty(value = "display") + 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" + */ + @JsonProperty(value = "origin", access = JsonProperty.Access.WRITE_ONLY) + private Origin origin; + + /* + * Enum. Indicates the action type. "Internal" refers to actions that are + * for internal only APIs. + */ + @JsonProperty(value = "actionType", access = JsonProperty.Access.WRITE_ONLY) + private ActionType actionType; + + /** + * 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 ARM/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; + } + + /** + * Set the display property: Localized display information for this particular operation. + * + * @param display the display value to set. + * @return the OperationInner object itself. + */ + public OperationInner withDisplay(OperationDisplay display) { + this.display = display; + return this; + } + + /** + * 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: 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(); + } + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/models/package-info.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/models/package-info.java new file mode 100644 index 000000000000..605a9728c356 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the inner data models for LoadTestClient. LoadTest client provides access to LoadTest Resource and + * it's status operations. + */ +package com.azure.resourcemanager.loadtestservice.fluent.models; diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/package-info.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/package-info.java new file mode 100644 index 000000000000..92e0c22cafca --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/fluent/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the service clients for LoadTestClient. LoadTest client provides access to LoadTest Resource and + * it's status operations. + */ +package com.azure.resourcemanager.loadtestservice.fluent; diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/LoadTestClientBuilder.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/LoadTestClientBuilder.java new file mode 100644 index 000000000000..94246872a282 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/LoadTestClientBuilder.java @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.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.CookiePolicy; +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 LoadTestClientImpl type. */ +@ServiceClientBuilder(serviceClients = {LoadTestClientImpl.class}) +public final class LoadTestClientBuilder { + /* + * The ID of the target subscription. + */ + private String subscriptionId; + + /** + * Sets The ID of the target subscription. + * + * @param subscriptionId the subscriptionId value. + * @return the LoadTestClientBuilder. + */ + public LoadTestClientBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * server parameter + */ + private String endpoint; + + /** + * Sets server parameter. + * + * @param endpoint the endpoint value. + * @return the LoadTestClientBuilder. + */ + public LoadTestClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the LoadTestClientBuilder. + */ + public LoadTestClientBuilder environment(AzureEnvironment environment) { + this.environment = environment; + 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 LoadTestClientBuilder. + */ + public LoadTestClientBuilder defaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = defaultPollInterval; + 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 LoadTestClientBuilder. + */ + public LoadTestClientBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + 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 LoadTestClientBuilder. + */ + public LoadTestClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of LoadTestClientImpl with the provided parameters. + * + * @return an instance of LoadTestClientImpl. + */ + public LoadTestClientImpl buildClient() { + if (endpoint == null) { + this.endpoint = "https://management.azure.com"; + } + if (environment == null) { + this.environment = AzureEnvironment.AZURE; + } + if (defaultPollInterval == null) { + this.defaultPollInterval = Duration.ofSeconds(30); + } + if (pipeline == null) { + this.pipeline = + new HttpPipelineBuilder() + .policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy()) + .build(); + } + if (serializerAdapter == null) { + this.serializerAdapter = SerializerFactory.createDefaultManagementSerializerAdapter(); + } + LoadTestClientImpl client = + new LoadTestClientImpl( + pipeline, serializerAdapter, defaultPollInterval, environment, subscriptionId, endpoint); + return client; + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/LoadTestClientImpl.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/LoadTestClientImpl.java new file mode 100644 index 000000000000..6bc14681d67e --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/LoadTestClientImpl.java @@ -0,0 +1,307 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.implementation; + +import com.azure.core.annotation.ServiceClient; +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.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.loadtestservice.fluent.LoadTestClient; +import com.azure.resourcemanager.loadtestservice.fluent.LoadTestsClient; +import com.azure.resourcemanager.loadtestservice.fluent.OperationsClient; +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 java.util.Map; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** Initializes a new instance of the LoadTestClientImpl type. */ +@ServiceClient(builder = LoadTestClientBuilder.class) +public final class LoadTestClientImpl implements LoadTestClient { + private final ClientLogger logger = new ClientLogger(LoadTestClientImpl.class); + + /** The ID of the target subscription. */ + private final String subscriptionId; + + /** + * Gets The ID of the target subscription. + * + * @return the subscriptionId value. + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** server parameter. */ + private final String endpoint; + + /** + * Gets server parameter. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** Api Version. */ + private final String apiVersion; + + /** + * Gets Api Version. + * + * @return the apiVersion value. + */ + public String getApiVersion() { + return this.apiVersion; + } + + /** 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 LoadTestsClient object to access its operations. */ + private final LoadTestsClient loadTests; + + /** + * Gets the LoadTestsClient object to access its operations. + * + * @return the LoadTestsClient object. + */ + public LoadTestsClient getLoadTests() { + return this.loadTests; + } + + /** + * Initializes an instance of LoadTestClient 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 subscriptionId The ID of the target subscription. + * @param endpoint server parameter. + */ + LoadTestClientImpl( + HttpPipeline httpPipeline, + SerializerAdapter serializerAdapter, + Duration defaultPollInterval, + AzureEnvironment environment, + String subscriptionId, + String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.subscriptionId = subscriptionId; + this.endpoint = endpoint; + this.apiVersion = "2021-12-01-preview"; + this.operations = new OperationsClientImpl(this); + this.loadTests = new LoadTestsClientImpl(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) { + for (Map.Entry entry : this.getContext().getValues().entrySet()) { + context = context.addData(entry.getKey(), entry.getValue()); + } + return 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(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)); + } + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/LoadTestResourceImpl.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/LoadTestResourceImpl.java new file mode 100644 index 000000000000..507f2c2f2d2e --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/LoadTestResourceImpl.java @@ -0,0 +1,215 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.implementation; + +import com.azure.core.management.Region; +import com.azure.core.util.Context; +import com.azure.resourcemanager.loadtestservice.fluent.models.LoadTestResourceInner; +import com.azure.resourcemanager.loadtestservice.models.LoadTestResource; +import com.azure.resourcemanager.loadtestservice.models.LoadTestResourcePatchRequestBody; +import com.azure.resourcemanager.loadtestservice.models.LoadTestResourcePatchRequestBodyProperties; +import com.azure.resourcemanager.loadtestservice.models.ResourceState; +import com.azure.resourcemanager.loadtestservice.models.SystemAssignedServiceIdentity; +import java.util.Collections; +import java.util.Map; + +public final class LoadTestResourceImpl + implements LoadTestResource, LoadTestResource.Definition, LoadTestResource.Update { + private LoadTestResourceInner innerObject; + + private final com.azure.resourcemanager.loadtestservice.LoadTestManager 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 SystemAssignedServiceIdentity identity() { + return this.innerModel().identity(); + } + + public String description() { + return this.innerModel().description(); + } + + public ResourceState provisioningState() { + return this.innerModel().provisioningState(); + } + + public String dataPlaneUri() { + return this.innerModel().dataPlaneUri(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public LoadTestResourceInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.loadtestservice.LoadTestManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String loadTestName; + + private LoadTestResourcePatchRequestBody updateLoadTestResourcePatchRequestBody; + + public LoadTestResourceImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public LoadTestResource create() { + this.innerObject = + serviceManager + .serviceClient() + .getLoadTests() + .createOrUpdateWithResponse(resourceGroupName, loadTestName, this.innerModel(), Context.NONE) + .getValue(); + return this; + } + + public LoadTestResource create(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getLoadTests() + .createOrUpdateWithResponse(resourceGroupName, loadTestName, this.innerModel(), context) + .getValue(); + return this; + } + + LoadTestResourceImpl(String name, com.azure.resourcemanager.loadtestservice.LoadTestManager serviceManager) { + this.innerObject = new LoadTestResourceInner(); + this.serviceManager = serviceManager; + this.loadTestName = name; + } + + public LoadTestResourceImpl update() { + this.updateLoadTestResourcePatchRequestBody = new LoadTestResourcePatchRequestBody(); + return this; + } + + public LoadTestResource apply() { + this.innerObject = + serviceManager + .serviceClient() + .getLoadTests() + .updateWithResponse( + resourceGroupName, loadTestName, updateLoadTestResourcePatchRequestBody, Context.NONE) + .getValue(); + return this; + } + + public LoadTestResource apply(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getLoadTests() + .updateWithResponse(resourceGroupName, loadTestName, updateLoadTestResourcePatchRequestBody, context) + .getValue(); + return this; + } + + LoadTestResourceImpl( + LoadTestResourceInner innerObject, com.azure.resourcemanager.loadtestservice.LoadTestManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = Utils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.loadTestName = Utils.getValueFromIdByName(innerObject.id(), "loadTests"); + } + + public LoadTestResource refresh() { + this.innerObject = + serviceManager + .serviceClient() + .getLoadTests() + .getByResourceGroupWithResponse(resourceGroupName, loadTestName, Context.NONE) + .getValue(); + return this; + } + + public LoadTestResource refresh(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getLoadTests() + .getByResourceGroupWithResponse(resourceGroupName, loadTestName, context) + .getValue(); + return this; + } + + public LoadTestResourceImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public LoadTestResourceImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public LoadTestResourceImpl withTags(Map tags) { + this.innerModel().withTags(tags); + return this; + } + + public LoadTestResourceImpl withIdentity(SystemAssignedServiceIdentity identity) { + if (isInCreateMode()) { + this.innerModel().withIdentity(identity); + return this; + } else { + this.updateLoadTestResourcePatchRequestBody.withIdentity(identity); + return this; + } + } + + public LoadTestResourceImpl withDescription(String description) { + this.innerModel().withDescription(description); + return this; + } + + public LoadTestResourceImpl withTags(Object tags) { + this.updateLoadTestResourcePatchRequestBody.withTags(tags); + return this; + } + + public LoadTestResourceImpl withProperties(LoadTestResourcePatchRequestBodyProperties properties) { + this.updateLoadTestResourcePatchRequestBody.withProperties(properties); + return this; + } + + private boolean isInCreateMode() { + return this.innerModel().id() == null; + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/LoadTestsClientImpl.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/LoadTestsClientImpl.java new file mode 100644 index 000000000000..b3ce71020396 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/LoadTestsClientImpl.java @@ -0,0 +1,1361 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.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.logging.ClientLogger; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.loadtestservice.fluent.LoadTestsClient; +import com.azure.resourcemanager.loadtestservice.fluent.models.LoadTestResourceInner; +import com.azure.resourcemanager.loadtestservice.models.LoadTestResourcePageList; +import com.azure.resourcemanager.loadtestservice.models.LoadTestResourcePatchRequestBody; +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 LoadTestsClient. */ +public final class LoadTestsClientImpl implements LoadTestsClient { + private final ClientLogger logger = new ClientLogger(LoadTestsClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final LoadTestsService service; + + /** The service client containing this operation class. */ + private final LoadTestClientImpl client; + + /** + * Initializes an instance of LoadTestsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + LoadTestsClientImpl(LoadTestClientImpl client) { + this.service = + RestProxy.create(LoadTestsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for LoadTestClientLoadTests to be used by the proxy service to perform + * REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "LoadTestClientLoadTe") + private interface LoadTestsService { + @Headers({"Content-Type: application/json"}) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.LoadTestService/loadTests") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService" + + "/loadTests") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroup( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService" + + "/loadTests/{loadTestName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @QueryParam("api-version") String apiVersion, + @PathParam("loadTestName") String loadTestName, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Put( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService" + + "/loadTests/{loadTestName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createOrUpdate( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @QueryParam("api-version") String apiVersion, + @PathParam("loadTestName") String loadTestName, + @BodyParam("application/json") LoadTestResourceInner loadTestResource, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Patch( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService" + + "/loadTests/{loadTestName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> update( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @QueryParam("api-version") String apiVersion, + @PathParam("loadTestName") String loadTestName, + @BodyParam("application/json") LoadTestResourcePatchRequestBody loadTestResourcePatchRequestBody, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Delete( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService" + + "/loadTests/{loadTestName}") + @ExpectedResponses({200, 202, 204}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> delete( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @QueryParam("api-version") String apiVersion, + @PathParam("loadTestName") String loadTestName, + @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("$host") String endpoint, + @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("$host") String endpoint, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * Lists loadtests resources in a 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 list of resources page result. + */ + @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.getSubscriptionId(), + 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())); + } + + /** + * Lists loadtests resources in a 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 list of resources page result. + */ + @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.getSubscriptionId(), + this.client.getApiVersion(), + accept, + context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Lists loadtests resources in a 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 list of resources page result. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>( + () -> listSinglePageAsync(), nextLink -> listBySubscriptionNextSinglePageAsync(nextLink)); + } + + /** + * Lists loadtests resources in a 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 list of resources page result. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(context), nextLink -> listBySubscriptionNextSinglePageAsync(nextLink, context)); + } + + /** + * Lists loadtests resources in a 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 list of resources page result. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * Lists loadtests resources in a 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 list of resources page result. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Lists loadtest resources in a 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 list of resources page result. + */ + @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.getSubscriptionId(), + resourceGroupName, + 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())); + } + + /** + * Lists loadtest resources in a 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 list of resources page result. + */ + @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.getSubscriptionId(), + resourceGroupName, + this.client.getApiVersion(), + accept, + context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Lists loadtest resources in a 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 list of resources page result. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName) { + return new PagedFlux<>( + () -> listByResourceGroupSinglePageAsync(resourceGroupName), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink)); + } + + /** + * Lists loadtest resources in a 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 list of resources page result. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName, Context context) { + return new PagedFlux<>( + () -> listByResourceGroupSinglePageAsync(resourceGroupName, context), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink, context)); + } + + /** + * Lists loadtest resources in a 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 list of resources page result. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName)); + } + + /** + * Lists loadtest resources in a 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 list of resources page result. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context)); + } + + /** + * Get a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 LoadTest resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync( + String resourceGroupName, String loadTestName) { + 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 (loadTestName == null) { + return Mono.error(new IllegalArgumentException("Parameter loadTestName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .getByResourceGroup( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + this.client.getApiVersion(), + loadTestName, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 LoadTest resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync( + String resourceGroupName, String loadTestName, 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 (loadTestName == null) { + return Mono.error(new IllegalArgumentException("Parameter loadTestName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .getByResourceGroup( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + this.client.getApiVersion(), + loadTestName, + accept, + context); + } + + /** + * Get a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 LoadTest resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, String loadTestName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, loadTestName) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Get a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 LoadTest resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public LoadTestResourceInner getByResourceGroup(String resourceGroupName, String loadTestName) { + return getByResourceGroupAsync(resourceGroupName, loadTestName).block(); + } + + /** + * Get a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 LoadTest resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse( + String resourceGroupName, String loadTestName, Context context) { + return getByResourceGroupWithResponseAsync(resourceGroupName, loadTestName, context).block(); + } + + /** + * Create or update LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param loadTestResource LoadTest resource data. + * @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 loadTest details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync( + String resourceGroupName, String loadTestName, LoadTestResourceInner loadTestResource) { + 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 (loadTestName == null) { + return Mono.error(new IllegalArgumentException("Parameter loadTestName is required and cannot be null.")); + } + if (loadTestResource == null) { + return Mono + .error(new IllegalArgumentException("Parameter loadTestResource is required and cannot be null.")); + } else { + loadTestResource.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .createOrUpdate( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + this.client.getApiVersion(), + loadTestName, + loadTestResource, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create or update LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param loadTestResource LoadTest resource data. + * @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 loadTest details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync( + String resourceGroupName, String loadTestName, LoadTestResourceInner loadTestResource, 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 (loadTestName == null) { + return Mono.error(new IllegalArgumentException("Parameter loadTestName is required and cannot be null.")); + } + if (loadTestResource == null) { + return Mono + .error(new IllegalArgumentException("Parameter loadTestResource is required and cannot be null.")); + } else { + loadTestResource.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .createOrUpdate( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + this.client.getApiVersion(), + loadTestName, + loadTestResource, + accept, + context); + } + + /** + * Create or update LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param loadTestResource LoadTest resource data. + * @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 loadTest details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync( + String resourceGroupName, String loadTestName, LoadTestResourceInner loadTestResource) { + return createOrUpdateWithResponseAsync(resourceGroupName, loadTestName, loadTestResource) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Create or update LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param loadTestResource LoadTest resource data. + * @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 loadTest details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public LoadTestResourceInner createOrUpdate( + String resourceGroupName, String loadTestName, LoadTestResourceInner loadTestResource) { + return createOrUpdateAsync(resourceGroupName, loadTestName, loadTestResource).block(); + } + + /** + * Create or update LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param loadTestResource LoadTest resource data. + * @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 loadTest details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse( + String resourceGroupName, String loadTestName, LoadTestResourceInner loadTestResource, Context context) { + return createOrUpdateWithResponseAsync(resourceGroupName, loadTestName, loadTestResource, context).block(); + } + + /** + * Update a loadtest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param loadTestResourcePatchRequestBody LoadTest resource update data. + * @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 loadTest details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync( + String resourceGroupName, + String loadTestName, + LoadTestResourcePatchRequestBody loadTestResourcePatchRequestBody) { + 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 (loadTestName == null) { + return Mono.error(new IllegalArgumentException("Parameter loadTestName is required and cannot be null.")); + } + if (loadTestResourcePatchRequestBody == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter loadTestResourcePatchRequestBody is required and cannot be null.")); + } else { + loadTestResourcePatchRequestBody.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .update( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + this.client.getApiVersion(), + loadTestName, + loadTestResourcePatchRequestBody, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update a loadtest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param loadTestResourcePatchRequestBody LoadTest resource update data. + * @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 loadTest details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync( + String resourceGroupName, + String loadTestName, + LoadTestResourcePatchRequestBody loadTestResourcePatchRequestBody, + 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 (loadTestName == null) { + return Mono.error(new IllegalArgumentException("Parameter loadTestName is required and cannot be null.")); + } + if (loadTestResourcePatchRequestBody == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter loadTestResourcePatchRequestBody is required and cannot be null.")); + } else { + loadTestResourcePatchRequestBody.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .update( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + this.client.getApiVersion(), + loadTestName, + loadTestResourcePatchRequestBody, + accept, + context); + } + + /** + * Update a loadtest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param loadTestResourcePatchRequestBody LoadTest resource update data. + * @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 loadTest details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync( + String resourceGroupName, + String loadTestName, + LoadTestResourcePatchRequestBody loadTestResourcePatchRequestBody) { + return updateWithResponseAsync(resourceGroupName, loadTestName, loadTestResourcePatchRequestBody) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Update a loadtest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param loadTestResourcePatchRequestBody LoadTest resource update data. + * @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 loadTest details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public LoadTestResourceInner update( + String resourceGroupName, + String loadTestName, + LoadTestResourcePatchRequestBody loadTestResourcePatchRequestBody) { + return updateAsync(resourceGroupName, loadTestName, loadTestResourcePatchRequestBody).block(); + } + + /** + * Update a loadtest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param loadTestResourcePatchRequestBody LoadTest resource update data. + * @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 loadTest details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateWithResponse( + String resourceGroupName, + String loadTestName, + LoadTestResourcePatchRequestBody loadTestResourcePatchRequestBody, + Context context) { + return updateWithResponseAsync(resourceGroupName, loadTestName, loadTestResourcePatchRequestBody, context) + .block(); + } + + /** + * Delete a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> deleteWithResponseAsync(String resourceGroupName, String loadTestName) { + 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 (loadTestName == null) { + return Mono.error(new IllegalArgumentException("Parameter loadTestName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .delete( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + this.client.getApiVersion(), + loadTestName, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> deleteWithResponseAsync( + String resourceGroupName, String loadTestName, 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 (loadTestName == null) { + return Mono.error(new IllegalArgumentException("Parameter loadTestName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .delete( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + this.client.getApiVersion(), + loadTestName, + accept, + context); + } + + /** + * Delete a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 completion. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, String loadTestName) { + Mono>> mono = deleteWithResponseAsync(resourceGroupName, loadTestName); + return this + .client + .getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, Context.NONE); + } + + /** + * Delete a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 completion. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync( + String resourceGroupName, String loadTestName, Context context) { + context = this.client.mergeContext(context); + Mono>> mono = deleteWithResponseAsync(resourceGroupName, loadTestName, context); + return this + .client + .getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context); + } + + /** + * Delete a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 completion. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, String loadTestName) { + return beginDeleteAsync(resourceGroupName, loadTestName).getSyncPoller(); + } + + /** + * Delete a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 completion. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete( + String resourceGroupName, String loadTestName, Context context) { + return beginDeleteAsync(resourceGroupName, loadTestName, context).getSyncPoller(); + } + + /** + * Delete a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String loadTestName) { + return beginDeleteAsync(resourceGroupName, loadTestName).last().flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String loadTestName, Context context) { + return beginDeleteAsync(resourceGroupName, loadTestName, context) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 loadTestName) { + deleteAsync(resourceGroupName, loadTestName).block(); + } + + /** + * Delete a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 loadTestName, Context context) { + deleteAsync(resourceGroupName, loadTestName, context).block(); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @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 list of resources page result. + */ + @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 nextLink parameter. + * @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 list of resources page result. + */ + @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)); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @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 list of resources page result. + */ + @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 nextLink parameter. + * @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 list of resources page result. + */ + @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)); + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/LoadTestsImpl.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/LoadTestsImpl.java new file mode 100644 index 000000000000..c610187b7ba2 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/LoadTestsImpl.java @@ -0,0 +1,171 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.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.loadtestservice.fluent.LoadTestsClient; +import com.azure.resourcemanager.loadtestservice.fluent.models.LoadTestResourceInner; +import com.azure.resourcemanager.loadtestservice.models.LoadTestResource; +import com.azure.resourcemanager.loadtestservice.models.LoadTests; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public final class LoadTestsImpl implements LoadTests { + @JsonIgnore private final ClientLogger logger = new ClientLogger(LoadTestsImpl.class); + + private final LoadTestsClient innerClient; + + private final com.azure.resourcemanager.loadtestservice.LoadTestManager serviceManager; + + public LoadTestsImpl( + LoadTestsClient innerClient, com.azure.resourcemanager.loadtestservice.LoadTestManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return Utils.mapPage(inner, inner1 -> new LoadTestResourceImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return Utils.mapPage(inner, inner1 -> new LoadTestResourceImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName); + return Utils.mapPage(inner, inner1 -> new LoadTestResourceImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + PagedIterable inner = + this.serviceClient().listByResourceGroup(resourceGroupName, context); + return Utils.mapPage(inner, inner1 -> new LoadTestResourceImpl(inner1, this.manager())); + } + + public LoadTestResource getByResourceGroup(String resourceGroupName, String loadTestName) { + LoadTestResourceInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, loadTestName); + if (inner != null) { + return new LoadTestResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response getByResourceGroupWithResponse( + String resourceGroupName, String loadTestName, Context context) { + Response inner = + this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, loadTestName, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new LoadTestResourceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public void deleteByResourceGroup(String resourceGroupName, String loadTestName) { + this.serviceClient().delete(resourceGroupName, loadTestName); + } + + public void delete(String resourceGroupName, String loadTestName, Context context) { + this.serviceClient().delete(resourceGroupName, loadTestName, context); + } + + public LoadTestResource getById(String id) { + String resourceGroupName = Utils.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 loadTestName = Utils.getValueFromIdByName(id, "loadTests"); + if (loadTestName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'loadTests'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, loadTestName, Context.NONE).getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceGroupName = Utils.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 loadTestName = Utils.getValueFromIdByName(id, "loadTests"); + if (loadTestName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'loadTests'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, loadTestName, context); + } + + public void deleteById(String id) { + String resourceGroupName = Utils.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 loadTestName = Utils.getValueFromIdByName(id, "loadTests"); + if (loadTestName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'loadTests'.", id))); + } + this.delete(resourceGroupName, loadTestName, Context.NONE); + } + + public void deleteByIdWithResponse(String id, Context context) { + String resourceGroupName = Utils.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 loadTestName = Utils.getValueFromIdByName(id, "loadTests"); + if (loadTestName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'loadTests'.", id))); + } + this.delete(resourceGroupName, loadTestName, context); + } + + private LoadTestsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.loadtestservice.LoadTestManager manager() { + return this.serviceManager; + } + + public LoadTestResourceImpl define(String name) { + return new LoadTestResourceImpl(name, this.manager()); + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/OperationImpl.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/OperationImpl.java new file mode 100644 index 000000000000..389105beedc8 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/OperationImpl.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.implementation; + +import com.azure.resourcemanager.loadtestservice.fluent.models.OperationInner; +import com.azure.resourcemanager.loadtestservice.models.ActionType; +import com.azure.resourcemanager.loadtestservice.models.Operation; +import com.azure.resourcemanager.loadtestservice.models.OperationDisplay; +import com.azure.resourcemanager.loadtestservice.models.Origin; + +public final class OperationImpl implements Operation { + private OperationInner innerObject; + + private final com.azure.resourcemanager.loadtestservice.LoadTestManager serviceManager; + + OperationImpl( + OperationInner innerObject, com.azure.resourcemanager.loadtestservice.LoadTestManager 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.loadtestservice.LoadTestManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/OperationsClientImpl.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/OperationsClientImpl.java new file mode 100644 index 000000000000..b9db9f7c60a6 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/OperationsClientImpl.java @@ -0,0 +1,269 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.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.core.util.logging.ClientLogger; +import com.azure.resourcemanager.loadtestservice.fluent.OperationsClient; +import com.azure.resourcemanager.loadtestservice.fluent.models.OperationInner; +import com.azure.resourcemanager.loadtestservice.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 { + private final ClientLogger logger = new ClientLogger(OperationsClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final OperationsService service; + + /** The service client containing this operation class. */ + private final LoadTestClientImpl client; + + /** + * Initializes an instance of OperationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationsClientImpl(LoadTestClientImpl client) { + this.service = + RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for LoadTestClientOperations to be used by the proxy service to perform + * REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "LoadTestClientOperat") + private interface OperationsService { + @Headers({"Content-Type: application/json"}) + @Get("/providers/Microsoft.LoadTestService/operations") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list( + @HostParam("$host") 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("$host") String endpoint, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * Lists all the available API operations for Load Test Resource. + * + * @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. + */ + @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())); + } + + /** + * Lists all the available API operations for Load Test Resource. + * + * @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. + */ + @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)); + } + + /** + * Lists all the available API operations for Load Test Resource. + * + * @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. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * Lists all the available API operations for Load Test Resource. + * + * @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. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(context), nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * Lists all the available API operations for Load Test Resource. + * + * @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. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * Lists all the available API operations for Load Test Resource. + * + * @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. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @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. + */ + @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 nextLink parameter. + * @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. + */ + @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/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/OperationsImpl.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/OperationsImpl.java new file mode 100644 index 000000000000..f02585ed7718 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/OperationsImpl.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.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.loadtestservice.fluent.OperationsClient; +import com.azure.resourcemanager.loadtestservice.fluent.models.OperationInner; +import com.azure.resourcemanager.loadtestservice.models.Operation; +import com.azure.resourcemanager.loadtestservice.models.Operations; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public final class OperationsImpl implements Operations { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationsImpl.class); + + private final OperationsClient innerClient; + + private final com.azure.resourcemanager.loadtestservice.LoadTestManager serviceManager; + + public OperationsImpl( + OperationsClient innerClient, com.azure.resourcemanager.loadtestservice.LoadTestManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return Utils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return Utils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + private OperationsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.loadtestservice.LoadTestManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/Utils.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/Utils.java new file mode 100644 index 000000000000..06515901600b --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/Utils.java @@ -0,0 +1,204 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.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 Utils { + 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.size() > 0 && 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, PagedResponse>(pagedIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl, PagedResponse>( + pagedIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl, PagedResponse>( + pagedIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl, PagedResponse>( + 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/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/package-info.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/package-info.java new file mode 100644 index 000000000000..98fd44e9c122 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/implementation/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the implementations for LoadTestClient. LoadTest client provides access to LoadTest Resource and + * it's status operations. + */ +package com.azure.resourcemanager.loadtestservice.implementation; diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/ActionType.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/ActionType.java new file mode 100644 index 000000000000..e044e209ab78 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/ActionType.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for ActionType. */ +public final class ActionType extends ExpandableStringEnum { + /** Static value Internal for ActionType. */ + public static final ActionType INTERNAL = fromString("Internal"); + + /** + * Creates or finds a ActionType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ActionType. + */ + @JsonCreator + public static ActionType fromString(String name) { + return fromString(name, ActionType.class); + } + + /** @return known ActionType values. */ + public static Collection values() { + return values(ActionType.class); + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/LoadTestResource.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/LoadTestResource.java new file mode 100644 index 000000000000..bfd676983e38 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/LoadTestResource.java @@ -0,0 +1,261 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.models; + +import com.azure.core.management.Region; +import com.azure.core.util.Context; +import com.azure.resourcemanager.loadtestservice.fluent.models.LoadTestResourceInner; +import java.util.Map; + +/** An immutable client-side representation of LoadTestResource. */ +public interface LoadTestResource { + /** + * 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 identity property: The type of identity used for the resource. + * + * @return the identity value. + */ + SystemAssignedServiceIdentity identity(); + + /** + * Gets the description property: Description of the resource. + * + * @return the description value. + */ + String description(); + + /** + * Gets the provisioningState property: Resource provisioning state. + * + * @return the provisioningState value. + */ + ResourceState provisioningState(); + + /** + * Gets the dataPlaneUri property: Resource data plane URI. + * + * @return the dataPlaneUri value. + */ + String dataPlaneUri(); + + /** + * 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 inner com.azure.resourcemanager.loadtestservice.fluent.models.LoadTestResourceInner object. + * + * @return the inner object. + */ + LoadTestResourceInner innerModel(); + + /** The entirety of the LoadTestResource definition. */ + interface Definition + extends DefinitionStages.Blank, + DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, + DefinitionStages.WithCreate { + } + /** The LoadTestResource definition stages. */ + interface DefinitionStages { + /** The first stage of the LoadTestResource definition. */ + interface Blank extends WithLocation { + } + /** The stage of the LoadTestResource 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 LoadTestResource 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 LoadTestResource 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.WithIdentity, DefinitionStages.WithDescription { + /** + * Executes the create request. + * + * @return the created resource. + */ + LoadTestResource create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + LoadTestResource create(Context context); + } + /** The stage of the LoadTestResource 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 LoadTestResource definition allowing to specify identity. */ + interface WithIdentity { + /** + * Specifies the identity property: The type of identity used for the resource.. + * + * @param identity The type of identity used for the resource. + * @return the next definition stage. + */ + WithCreate withIdentity(SystemAssignedServiceIdentity identity); + } + /** The stage of the LoadTestResource definition allowing to specify description. */ + interface WithDescription { + /** + * Specifies the description property: Description of the resource.. + * + * @param description Description of the resource. + * @return the next definition stage. + */ + WithCreate withDescription(String description); + } + } + /** + * Begins update for the LoadTestResource resource. + * + * @return the stage of resource update. + */ + LoadTestResource.Update update(); + + /** The template for LoadTestResource update. */ + interface Update extends UpdateStages.WithTags, UpdateStages.WithIdentity, UpdateStages.WithProperties { + /** + * Executes the update request. + * + * @return the updated resource. + */ + LoadTestResource apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + LoadTestResource apply(Context context); + } + /** The LoadTestResource update stages. */ + interface UpdateStages { + /** The stage of the LoadTestResource update allowing to specify tags. */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + Update withTags(Object tags); + } + /** The stage of the LoadTestResource update allowing to specify identity. */ + interface WithIdentity { + /** + * Specifies the identity property: The type of identity used for the resource.. + * + * @param identity The type of identity used for the resource. + * @return the next definition stage. + */ + Update withIdentity(SystemAssignedServiceIdentity identity); + } + /** The stage of the LoadTestResource update allowing to specify properties. */ + interface WithProperties { + /** + * Specifies the properties property: Load Test resource properties. + * + * @param properties Load Test resource properties. + * @return the next definition stage. + */ + Update withProperties(LoadTestResourcePatchRequestBodyProperties properties); + } + } + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + LoadTestResource refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + LoadTestResource refresh(Context context); +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/LoadTestResourcePageList.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/LoadTestResourcePageList.java new file mode 100644 index 000000000000..4ab558583389 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/LoadTestResourcePageList.java @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.loadtestservice.fluent.models.LoadTestResourceInner; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** List of resources page result. */ +@Fluent +public final class LoadTestResourcePageList { + @JsonIgnore private final ClientLogger logger = new ClientLogger(LoadTestResourcePageList.class); + + /* + * List of resources in current page. + */ + @JsonProperty(value = "value") + private List value; + + /* + * Link to next page of resources. + */ + @JsonProperty(value = "nextLink") + private String nextLink; + + /** + * Get the value property: List of resources in current page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: List of resources in current page. + * + * @param value the value value to set. + * @return the LoadTestResourcePageList object itself. + */ + public LoadTestResourcePageList withValue(List value) { + this.value = value; + return this; + } + + /** + * Get the nextLink property: Link to next page of resources. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Set the nextLink property: Link to next page of resources. + * + * @param nextLink the nextLink value to set. + * @return the LoadTestResourcePageList object itself. + */ + public LoadTestResourcePageList withNextLink(String nextLink) { + this.nextLink = nextLink; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() != null) { + value().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/LoadTestResourcePatchRequestBody.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/LoadTestResourcePatchRequestBody.java new file mode 100644 index 000000000000..49cf2c14149d --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/LoadTestResourcePatchRequestBody.java @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** LoadTest resource patch request body. */ +@Fluent +public final class LoadTestResourcePatchRequestBody { + @JsonIgnore private final ClientLogger logger = new ClientLogger(LoadTestResourcePatchRequestBody.class); + + /* + * Resource tags. + */ + @JsonProperty(value = "tags") + private Object tags; + + /* + * The type of identity used for the resource. + */ + @JsonProperty(value = "identity") + private SystemAssignedServiceIdentity identity; + + /* + * Load Test resource properties + */ + @JsonProperty(value = "properties") + private LoadTestResourcePatchRequestBodyProperties properties; + + /** + * Get the tags property: Resource tags. + * + * @return the tags value. + */ + public Object tags() { + return this.tags; + } + + /** + * Set the tags property: Resource tags. + * + * @param tags the tags value to set. + * @return the LoadTestResourcePatchRequestBody object itself. + */ + public LoadTestResourcePatchRequestBody withTags(Object tags) { + this.tags = tags; + return this; + } + + /** + * Get the identity property: The type of identity used for the resource. + * + * @return the identity value. + */ + public SystemAssignedServiceIdentity identity() { + return this.identity; + } + + /** + * Set the identity property: The type of identity used for the resource. + * + * @param identity the identity value to set. + * @return the LoadTestResourcePatchRequestBody object itself. + */ + public LoadTestResourcePatchRequestBody withIdentity(SystemAssignedServiceIdentity identity) { + this.identity = identity; + return this; + } + + /** + * Get the properties property: Load Test resource properties. + * + * @return the properties value. + */ + public LoadTestResourcePatchRequestBodyProperties properties() { + return this.properties; + } + + /** + * Set the properties property: Load Test resource properties. + * + * @param properties the properties value to set. + * @return the LoadTestResourcePatchRequestBody object itself. + */ + public LoadTestResourcePatchRequestBody withProperties(LoadTestResourcePatchRequestBodyProperties properties) { + this.properties = properties; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (identity() != null) { + identity().validate(); + } + if (properties() != null) { + properties().validate(); + } + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/LoadTestResourcePatchRequestBodyProperties.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/LoadTestResourcePatchRequestBodyProperties.java new file mode 100644 index 000000000000..235e4b752c2e --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/LoadTestResourcePatchRequestBodyProperties.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Load Test resource properties. */ +@Fluent +public final class LoadTestResourcePatchRequestBodyProperties { + @JsonIgnore private final ClientLogger logger = new ClientLogger(LoadTestResourcePatchRequestBodyProperties.class); + + /* + * Description of the resource. + */ + @JsonProperty(value = "description") + private String description; + + /** + * Get the description property: Description of the resource. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Set the description property: Description of the resource. + * + * @param description the description value to set. + * @return the LoadTestResourcePatchRequestBodyProperties object itself. + */ + public LoadTestResourcePatchRequestBodyProperties withDescription(String description) { + this.description = description; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/LoadTests.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/LoadTests.java new file mode 100644 index 000000000000..3b663a1e49d4 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/LoadTests.java @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.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 LoadTests. */ +public interface LoadTests { + /** + * Lists loadtests resources in a 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 list of resources page result. + */ + PagedIterable list(); + + /** + * Lists loadtests resources in a 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 list of resources page result. + */ + PagedIterable list(Context context); + + /** + * Lists loadtest resources in a 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 list of resources page result. + */ + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * Lists loadtest resources in a 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 list of resources page result. + */ + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Get a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 LoadTest resource. + */ + LoadTestResource getByResourceGroup(String resourceGroupName, String loadTestName); + + /** + * Get a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 LoadTest resource. + */ + Response getByResourceGroupWithResponse( + String resourceGroupName, String loadTestName, Context context); + + /** + * Delete a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 loadTestName); + + /** + * Delete a LoadTest resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @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 loadTestName, Context context); + + /** + * Get a LoadTest resource. + * + * @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 LoadTest resource. + */ + LoadTestResource getById(String id); + + /** + * Get a LoadTest resource. + * + * @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 LoadTest resource. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a LoadTest resource. + * + * @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 LoadTest resource. + * + * @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 LoadTestResource resource. + * + * @param name resource name. + * @return the first stage of the new LoadTestResource definition. + */ + LoadTestResource.DefinitionStages.Blank define(String name); +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/Operation.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/Operation.java new file mode 100644 index 000000000000..6a28cf521e88 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/Operation.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.models; + +import com.azure.resourcemanager.loadtestservice.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 ARM/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: 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.loadtestservice.fluent.models.OperationInner object. + * + * @return the inner object. + */ + OperationInner innerModel(); +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/OperationDisplay.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/OperationDisplay.java new file mode 100644 index 000000000000..cf1642697d56 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/OperationDisplay.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Localized display information for this particular operation. */ +@Immutable +public final class OperationDisplay { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationDisplay.class); + + /* + * The localized friendly form of the resource provider name, e.g. + * "Microsoft Monitoring Insights" or "Microsoft Compute". + */ + @JsonProperty(value = "provider", access = JsonProperty.Access.WRITE_ONLY) + private String provider; + + /* + * The localized friendly name of the resource type related to this + * operation. E.g. "Virtual Machines" or "Job Schedule Collections". + */ + @JsonProperty(value = "resource", access = JsonProperty.Access.WRITE_ONLY) + private String resource; + + /* + * The concise, localized friendly name for the operation; suitable for + * dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual + * Machine". + */ + @JsonProperty(value = "operation", access = JsonProperty.Access.WRITE_ONLY) + private String operation; + + /* + * The short, localized friendly description of the operation; suitable for + * tool tips and detailed views. + */ + @JsonProperty(value = "description", access = JsonProperty.Access.WRITE_ONLY) + private String description; + + /** + * 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() { + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/OperationListResult.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/OperationListResult.java new file mode 100644 index 000000000000..ede805c153e1 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/OperationListResult.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.loadtestservice.fluent.models.OperationInner; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +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 { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationListResult.class); + + /* + * List of operations supported by the resource provider + */ + @JsonProperty(value = "value", access = JsonProperty.Access.WRITE_ONLY) + private List value; + + /* + * URL to get the next set of operation list results (if there are any). + */ + @JsonProperty(value = "nextLink", access = JsonProperty.Access.WRITE_ONLY) + private String nextLink; + + /** + * Get the value property: List of operations supported by the resource provider. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: URL to get the next set of operation list results (if there are any). + * + * @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) { + value().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/Operations.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/Operations.java new file mode 100644 index 000000000000..19896c3dd4d4 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/Operations.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; + +/** Resource collection API of Operations. */ +public interface Operations { + /** + * Lists all the available API operations for Load Test Resource. + * + * @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. + */ + PagedIterable list(); + + /** + * Lists all the available API operations for Load Test Resource. + * + * @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. + */ + PagedIterable list(Context context); +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/Origin.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/Origin.java new file mode 100644 index 000000000000..2c1cb5f69e0c --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/Origin.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for Origin. */ +public final class Origin extends ExpandableStringEnum { + /** Static value user for Origin. */ + public static final Origin USER = fromString("user"); + + /** Static value system for Origin. */ + public static final Origin SYSTEM = fromString("system"); + + /** Static value user,system for Origin. */ + public static final Origin USER_SYSTEM = fromString("user,system"); + + /** + * Creates or finds a Origin from its string representation. + * + * @param name a name to look for. + * @return the corresponding Origin. + */ + @JsonCreator + public static Origin fromString(String name) { + return fromString(name, Origin.class); + } + + /** @return known Origin values. */ + public static Collection values() { + return values(Origin.class); + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/ResourceState.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/ResourceState.java new file mode 100644 index 000000000000..513e29595753 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/ResourceState.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for ResourceState. */ +public final class ResourceState extends ExpandableStringEnum { + /** Static value Succeeded for ResourceState. */ + public static final ResourceState SUCCEEDED = fromString("Succeeded"); + + /** Static value Failed for ResourceState. */ + public static final ResourceState FAILED = fromString("Failed"); + + /** Static value Canceled for ResourceState. */ + public static final ResourceState CANCELED = fromString("Canceled"); + + /** Static value Deleted for ResourceState. */ + public static final ResourceState DELETED = fromString("Deleted"); + + /** + * Creates or finds a ResourceState from its string representation. + * + * @param name a name to look for. + * @return the corresponding ResourceState. + */ + @JsonCreator + public static ResourceState fromString(String name) { + return fromString(name, ResourceState.class); + } + + /** @return known ResourceState values. */ + public static Collection values() { + return values(ResourceState.class); + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/SystemAssignedServiceIdentity.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/SystemAssignedServiceIdentity.java new file mode 100644 index 000000000000..69dde442eccd --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/SystemAssignedServiceIdentity.java @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.UUID; + +/** Managed service identity (either system assigned, or none). */ +@Fluent +public class SystemAssignedServiceIdentity { + @JsonIgnore private final ClientLogger logger = new ClientLogger(SystemAssignedServiceIdentity.class); + + /* + * The service principal ID of the system assigned identity. This property + * will only be provided for a system assigned identity. + */ + @JsonProperty(value = "principalId", access = JsonProperty.Access.WRITE_ONLY) + private UUID principalId; + + /* + * The tenant ID of the system assigned identity. This property will only + * be provided for a system assigned identity. + */ + @JsonProperty(value = "tenantId", access = JsonProperty.Access.WRITE_ONLY) + private UUID tenantId; + + /* + * Type of managed service identity (either system assigned, or none). + */ + @JsonProperty(value = "type", required = true) + private SystemAssignedServiceIdentityType type; + + /** + * Get the principalId property: The service principal ID of the system assigned identity. This property will only + * be provided for a system assigned identity. + * + * @return the principalId value. + */ + public UUID principalId() { + return this.principalId; + } + + /** + * Get the tenantId property: The tenant ID of the system assigned identity. This property will only be provided for + * a system assigned identity. + * + * @return the tenantId value. + */ + public UUID tenantId() { + return this.tenantId; + } + + /** + * Get the type property: Type of managed service identity (either system assigned, or none). + * + * @return the type value. + */ + public SystemAssignedServiceIdentityType type() { + return this.type; + } + + /** + * Set the type property: Type of managed service identity (either system assigned, or none). + * + * @param type the type value to set. + * @return the SystemAssignedServiceIdentity object itself. + */ + public SystemAssignedServiceIdentity withType(SystemAssignedServiceIdentityType type) { + this.type = type; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (type() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + "Missing required property type in model SystemAssignedServiceIdentity")); + } + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/SystemAssignedServiceIdentityType.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/SystemAssignedServiceIdentityType.java new file mode 100644 index 000000000000..4dfe122809d1 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/SystemAssignedServiceIdentityType.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for SystemAssignedServiceIdentityType. */ +public final class SystemAssignedServiceIdentityType extends ExpandableStringEnum { + /** Static value None for SystemAssignedServiceIdentityType. */ + public static final SystemAssignedServiceIdentityType NONE = fromString("None"); + + /** Static value SystemAssigned for SystemAssignedServiceIdentityType. */ + public static final SystemAssignedServiceIdentityType SYSTEM_ASSIGNED = fromString("SystemAssigned"); + + /** + * Creates or finds a SystemAssignedServiceIdentityType from its string representation. + * + * @param name a name to look for. + * @return the corresponding SystemAssignedServiceIdentityType. + */ + @JsonCreator + public static SystemAssignedServiceIdentityType fromString(String name) { + return fromString(name, SystemAssignedServiceIdentityType.class); + } + + /** @return known SystemAssignedServiceIdentityType values. */ + public static Collection values() { + return values(SystemAssignedServiceIdentityType.class); + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/package-info.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/package-info.java new file mode 100644 index 000000000000..d08dfc4ad621 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the data models for LoadTestClient. LoadTest client provides access to LoadTest Resource and it's + * status operations. + */ +package com.azure.resourcemanager.loadtestservice.models; diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/package-info.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/package-info.java new file mode 100644 index 000000000000..9456dd5a10a4 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/com/azure/resourcemanager/loadtestservice/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the classes for LoadTestClient. LoadTest client provides access to LoadTest Resource and it's + * status operations. + */ +package com.azure.resourcemanager.loadtestservice; diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/module-info.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/module-info.java new file mode 100644 index 000000000000..3b21649d7c2f --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/main/java/module-info.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +module com.azure.resourcemanager.loadtestservice { + requires transitive com.azure.core.management; + + exports com.azure.resourcemanager.loadtestservice; + exports com.azure.resourcemanager.loadtestservice.fluent; + exports com.azure.resourcemanager.loadtestservice.fluent.models; + exports com.azure.resourcemanager.loadtestservice.models; + + opens com.azure.resourcemanager.loadtestservice.fluent.models to + com.azure.core, + com.fasterxml.jackson.databind; + opens com.azure.resourcemanager.loadtestservice.models to + com.azure.core, + com.fasterxml.jackson.databind; +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsCreateOrUpdateSamples.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsCreateOrUpdateSamples.java new file mode 100644 index 000000000000..df0b9f135771 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsCreateOrUpdateSamples.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.generated; + +import java.util.HashMap; +import java.util.Map; + +/** Samples for LoadTests CreateOrUpdate. */ +public final class LoadTestsCreateOrUpdateSamples { + /* + * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_CreateOrUpdate.json + */ + /** + * Sample code: LoadTests_CreateOrUpdate. + * + * @param manager Entry point to LoadTestManager. + */ + public static void loadTestsCreateOrUpdate(com.azure.resourcemanager.loadtestservice.LoadTestManager manager) { + manager + .loadTests() + .define("myLoadTest") + .withRegion("westus") + .withExistingResourceGroup("dummyrg") + .withTags(mapOf("Team", "Dev Exp")) + .withDescription("This is new load test resource") + .create(); + } + + @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/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsDeleteSamples.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsDeleteSamples.java new file mode 100644 index 000000000000..9a185d004065 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsDeleteSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.generated; + +import com.azure.core.util.Context; + +/** Samples for LoadTests Delete. */ +public final class LoadTestsDeleteSamples { + /* + * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_Delete.json + */ + /** + * Sample code: LoadTests_Delete. + * + * @param manager Entry point to LoadTestManager. + */ + public static void loadTestsDelete(com.azure.resourcemanager.loadtestservice.LoadTestManager manager) { + manager.loadTests().delete("dummyrg", "myLoadTest", Context.NONE); + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsGetByResourceGroupSamples.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsGetByResourceGroupSamples.java new file mode 100644 index 000000000000..98cf8b276b0a --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsGetByResourceGroupSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.generated; + +import com.azure.core.util.Context; + +/** Samples for LoadTests GetByResourceGroup. */ +public final class LoadTestsGetByResourceGroupSamples { + /* + * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_Get.json + */ + /** + * Sample code: LoadTests_Get. + * + * @param manager Entry point to LoadTestManager. + */ + public static void loadTestsGet(com.azure.resourcemanager.loadtestservice.LoadTestManager manager) { + manager.loadTests().getByResourceGroupWithResponse("dummyrg", "myLoadTest", Context.NONE); + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsListByResourceGroupSamples.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsListByResourceGroupSamples.java new file mode 100644 index 000000000000..e9cdfac4df42 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsListByResourceGroupSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.generated; + +import com.azure.core.util.Context; + +/** Samples for LoadTests ListByResourceGroup. */ +public final class LoadTestsListByResourceGroupSamples { + /* + * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_ListByResourceGroup.json + */ + /** + * Sample code: LoadTests_ListByResourceGroup. + * + * @param manager Entry point to LoadTestManager. + */ + public static void loadTestsListByResourceGroup(com.azure.resourcemanager.loadtestservice.LoadTestManager manager) { + manager.loadTests().listByResourceGroup("dummyrg", Context.NONE); + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsListSamples.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsListSamples.java new file mode 100644 index 000000000000..39118ffee2af --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsListSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.generated; + +import com.azure.core.util.Context; + +/** Samples for LoadTests List. */ +public final class LoadTestsListSamples { + /* + * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_ListBySubscription.json + */ + /** + * Sample code: LoadTests_ListBySubscription. + * + * @param manager Entry point to LoadTestManager. + */ + public static void loadTestsListBySubscription(com.azure.resourcemanager.loadtestservice.LoadTestManager manager) { + manager.loadTests().list(Context.NONE); + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsUpdateSamples.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsUpdateSamples.java new file mode 100644 index 000000000000..7513c7561a89 --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/LoadTestsUpdateSamples.java @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.generated; + +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.Context; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.loadtestservice.models.LoadTestResource; +import com.azure.resourcemanager.loadtestservice.models.LoadTestResourcePatchRequestBodyProperties; +import java.io.IOException; + +/** Samples for LoadTests Update. */ +public final class LoadTestsUpdateSamples { + /* + * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_Update.json + */ + /** + * Sample code: LoadTests_Update. + * + * @param manager Entry point to LoadTestManager. + */ + public static void loadTestsUpdate(com.azure.resourcemanager.loadtestservice.LoadTestManager manager) + throws IOException { + LoadTestResource resource = + manager.loadTests().getByResourceGroupWithResponse("dummyrg", "myLoadTest", Context.NONE).getValue(); + resource + .update() + .withTags( + SerializerFactory + .createDefaultManagementSerializerAdapter() + .deserialize("{\"Division\":\"LT\",\"Team\":\"Dev Exp\"}", Object.class, SerializerEncoding.JSON)) + .withProperties( + new LoadTestResourcePatchRequestBodyProperties().withDescription("This is new load test resource")) + .apply(); + } +} diff --git a/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/OperationsListSamples.java b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/OperationsListSamples.java new file mode 100644 index 000000000000..d7286b735e8b --- /dev/null +++ b/sdk/loadtestservice/azure-resourcemanager-loadtestservice/src/samples/java/com/azure/resourcemanager/loadtestservice/generated/OperationsListSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.loadtestservice.generated; + +import com.azure.core.util.Context; + +/** Samples for Operations List. */ +public final class OperationsListSamples { + /* + * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/Operations_List.json + */ + /** + * Sample code: Operations_List. + * + * @param manager Entry point to LoadTestManager. + */ + public static void operationsList(com.azure.resourcemanager.loadtestservice.LoadTestManager manager) { + manager.operations().list(Context.NONE); + } +} diff --git a/sdk/loadtestservice/ci.yml b/sdk/loadtestservice/ci.yml new file mode 100644 index 000000000000..9cf274db2fac --- /dev/null +++ b/sdk/loadtestservice/ci.yml @@ -0,0 +1,39 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/loadtestservice/ci.yml + - sdk/loadtestservice/azure-resourcemanager-loadtestservice/ + exclude: + - sdk/loadtestservice/pom.xml + - sdk/loadtestservice/azure-resourcemanager-loadtestservice/pom.xml + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/loadtestservice/ci.yml + - sdk/loadtestservice/azure-resourcemanager-loadtestservice/ + exclude: + - sdk/loadtestservice/pom.xml + - sdk/loadtestservice/azure-resourcemanager-loadtestservice/pom.xml + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: loadtestservice + Artifacts: + - name: azure-resourcemanager-loadtestservice + groupId: com.azure.resourcemanager + safeName: azureresourcemanagerloadtestservice diff --git a/sdk/loadtestservice/pom.xml b/sdk/loadtestservice/pom.xml new file mode 100644 index 000000000000..d5b69fd2abfe --- /dev/null +++ b/sdk/loadtestservice/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + com.azure + azure-loadtestservice-service + pom + 1.0.0 + + + + coverage + + + + + + + + + + org.jacoco + jacoco-maven-plugin + 0.8.5 + + + report-aggregate + verify + + report-aggregate + + + ${project.reporting.outputDirectory}/test-coverage + + + + + + + + + default + + true + + + azure-resourcemanager-loadtestservice + + + +