From 8f4a285b8b77f8e158ced5fca1ad8955369e9625 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 7 Apr 2022 19:14:38 +0000 Subject: [PATCH] CodeGen from PR 18606 in Azure/azure-rest-api-specs Merge a976ad844dc78d63f27744666004d3ab6c177c81 into e7d2d8c48cf6f8f63de7e252c467930449b5fd88 --- eng/versioning/version_client.txt | 1 + pom.xml | 1 + .../CHANGELOG.md | 5 + .../azure-resourcemanager-dashboard/README.md | 102 ++ .../azure-resourcemanager-dashboard/SAMPLE.md | 211 +++ .../azure-resourcemanager-dashboard/pom.xml | 55 + .../dashboard/DashboardManager.java | 290 ++++ .../fluent/DashboardManagementClient.java | 61 + .../dashboard/fluent/GrafanasClient.java | 245 +++ .../dashboard/fluent/OperationsClient.java | 38 + .../fluent/models/ManagedGrafanaInner.java | 142 ++ .../fluent/models/OperationResultInner.java | 116 ++ .../dashboard/fluent/models/package-info.java | 6 + .../dashboard/fluent/package-info.java | 6 + .../DashboardManagementClientBuilder.java | 148 ++ .../DashboardManagementClientImpl.java | 312 ++++ .../implementation/GrafanasClientImpl.java | 1453 +++++++++++++++++ .../implementation/GrafanasImpl.java | 169 ++ .../implementation/ManagedGrafanaImpl.java | 212 +++ .../implementation/OperationResultImpl.java | 51 + .../implementation/OperationsClientImpl.java | 274 ++++ .../implementation/OperationsImpl.java | 45 + .../dashboard/implementation/Utils.java | 204 +++ .../implementation/package-info.java | 6 + .../dashboard/models/ActionType.java | 31 + .../AutoGeneratedDomainNameLabelScope.java | 31 + .../dashboard/models/Grafanas.java | 156 ++ .../dashboard/models/IdentityType.java | 34 + .../dashboard/models/ManagedGrafana.java | 265 +++ .../models/ManagedGrafanaListResponse.java | 77 + .../models/ManagedGrafanaProperties.java | 129 ++ .../ManagedGrafanaUpdateParameters.java | 78 + .../dashboard/models/ManagedIdentity.java | 119 ++ .../dashboard/models/OperationDisplay.java | 83 + .../dashboard/models/OperationListResult.java | 58 + .../dashboard/models/OperationResult.java | 54 + .../dashboard/models/Operations.java | 33 + .../dashboard/models/Origin.java | 37 + .../dashboard/models/ProvisioningState.java | 55 + .../dashboard/models/ResourceSku.java | 54 + .../models/UserAssignedIdentity.java | 50 + .../dashboard/models/ZoneRedundancy.java | 34 + .../dashboard/models/package-info.java | 6 + .../dashboard/package-info.java | 6 + .../src/main/java/module-info.java | 19 + .../generated/GrafanaCreateSamples.java | 52 + .../generated/GrafanaDeleteSamples.java | 22 + .../GrafanaGetByResourceGroupSamples.java | 22 + .../GrafanaListByResourceGroupSamples.java | 22 + .../generated/GrafanaListSamples.java | 22 + .../generated/GrafanaUpdateSamples.java | 41 + .../generated/OperationsListSamples.java | 22 + sdk/dashboard/ci.yml | 39 + sdk/dashboard/pom.xml | 53 + 54 files changed, 5857 insertions(+) create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/CHANGELOG.md create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/README.md create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/SAMPLE.md create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/pom.xml create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/DashboardManager.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/DashboardManagementClient.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/GrafanasClient.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/OperationsClient.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/models/ManagedGrafanaInner.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/models/OperationResultInner.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/models/package-info.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/package-info.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/DashboardManagementClientBuilder.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/DashboardManagementClientImpl.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/GrafanasClientImpl.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/GrafanasImpl.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/ManagedGrafanaImpl.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/OperationResultImpl.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/OperationsClientImpl.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/OperationsImpl.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/Utils.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/package-info.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ActionType.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/AutoGeneratedDomainNameLabelScope.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/Grafanas.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/IdentityType.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ManagedGrafana.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ManagedGrafanaListResponse.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ManagedGrafanaProperties.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ManagedGrafanaUpdateParameters.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ManagedIdentity.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/OperationDisplay.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/OperationListResult.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/OperationResult.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/Operations.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/Origin.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ProvisioningState.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ResourceSku.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/UserAssignedIdentity.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ZoneRedundancy.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/package-info.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/package-info.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/module-info.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaCreateSamples.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaDeleteSamples.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaGetByResourceGroupSamples.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaListByResourceGroupSamples.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaListSamples.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaUpdateSamples.java create mode 100644 sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/OperationsListSamples.java create mode 100644 sdk/dashboard/ci.yml create mode 100644 sdk/dashboard/pom.xml diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 7f8bd364ae8ac..3d2024bca3f29 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -332,6 +332,7 @@ com.azure.resourcemanager:azure-resourcemanager-oep;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-dnsresolver;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-mobilenetwork;1.0.0-beta.2;1.0.0-beta.3 com.azure.resourcemanager:azure-resourcemanager-azureadexternalidentities;1.0.0-beta.1;1.0.0-beta.1 +com.azure.resourcemanager:azure-resourcemanager-dashboard;1.0.0-beta.1;1.0.0-beta.1 com.azure.tools:azure-sdk-archetype;1.0.0;1.0.0 com.azure.tools:azure-sdk-build-tool;1.0.0-beta.1;1.0.0-beta.2 diff --git a/pom.xml b/pom.xml index 76489cb77b347..ba604d611551c 100644 --- a/pom.xml +++ b/pom.xml @@ -873,6 +873,7 @@ sdk/cosmos sdk/costmanagement sdk/customerinsights + sdk/dashboard sdk/databox sdk/databoxedge sdk/databricks diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/CHANGELOG.md b/sdk/dashboard/azure-resourcemanager-dashboard/CHANGELOG.md new file mode 100644 index 0000000000000..2fdd17a01fe43 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0-beta.1 (2022-04-07) + +- Azure Resource Manager Dashboard client library for Java. This package contains Microsoft Azure SDK for Dashboard Management SDK. The Microsoft.Dashboard Rest API spec. Package tag package-2021-09-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/dashboard/azure-resourcemanager-dashboard/README.md b/sdk/dashboard/azure-resourcemanager-dashboard/README.md new file mode 100644 index 0000000000000..66845e87ce0ac --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/README.md @@ -0,0 +1,102 @@ +# Azure Resource Manager Dashboard client library for Java + +Azure Resource Manager Dashboard client library for Java. + +This package contains Microsoft Azure SDK for Dashboard Management SDK. The Microsoft.Dashboard Rest API spec. Package tag package-2021-09-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-dashboard;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-dashboard + 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(); +DashboardManager manager = DashboardManager + .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/dashboard/azure-resourcemanager-dashboard/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/dashboard/azure-resourcemanager-dashboard/SAMPLE.md b/sdk/dashboard/azure-resourcemanager-dashboard/SAMPLE.md new file mode 100644 index 0000000000000..a204cd1cf2b4d --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/SAMPLE.md @@ -0,0 +1,211 @@ +# Code snippets and samples + + +## Grafana + +- [Create](#grafana_create) +- [Delete](#grafana_delete) +- [GetByResourceGroup](#grafana_getbyresourcegroup) +- [List](#grafana_list) +- [ListByResourceGroup](#grafana_listbyresourcegroup) +- [Update](#grafana_update) + +## Operations + +- [List](#operations_list) +### Grafana_Create + +```java +import com.azure.resourcemanager.dashboard.models.IdentityType; +import com.azure.resourcemanager.dashboard.models.ManagedGrafanaProperties; +import com.azure.resourcemanager.dashboard.models.ManagedIdentity; +import com.azure.resourcemanager.dashboard.models.ProvisioningState; +import com.azure.resourcemanager.dashboard.models.ResourceSku; +import com.azure.resourcemanager.dashboard.models.ZoneRedundancy; +import java.util.HashMap; +import java.util.Map; + +/** Samples for Grafana Create. */ +public final class GrafanaCreateSamples { + /* + * x-ms-original-file: specification/dashboard/resource-manager/Microsoft.Dashboard/preview/2021-09-01-preview/examples/Grafana_Create.json + */ + /** + * Sample code: Grafana_Create. + * + * @param manager Entry point to DashboardManager. + */ + public static void grafanaCreate(com.azure.resourcemanager.dashboard.DashboardManager manager) { + manager + .grafanas() + .define("myWorkspace") + .withRegion("West US") + .withExistingResourceGroup("myResourceGroup") + .withTags(mapOf("Environment", "Dev")) + .withSku(new ResourceSku().withName("Standard")) + .withProperties( + new ManagedGrafanaProperties() + .withProvisioningState(ProvisioningState.ACCEPTED) + .withZoneRedundancy(ZoneRedundancy.ENABLED)) + .withIdentity(new ManagedIdentity().withType(IdentityType.SYSTEM_ASSIGNED)) + .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; + } +} +``` + +### Grafana_Delete + +```java +import com.azure.core.util.Context; + +/** Samples for Grafana Delete. */ +public final class GrafanaDeleteSamples { + /* + * x-ms-original-file: specification/dashboard/resource-manager/Microsoft.Dashboard/preview/2021-09-01-preview/examples/Grafana_Delete.json + */ + /** + * Sample code: Grafana_Delete. + * + * @param manager Entry point to DashboardManager. + */ + public static void grafanaDelete(com.azure.resourcemanager.dashboard.DashboardManager manager) { + manager.grafanas().delete("myResourceGroup", "myWorkspace", Context.NONE); + } +} +``` + +### Grafana_GetByResourceGroup + +```java +import com.azure.core.util.Context; + +/** Samples for Grafana GetByResourceGroup. */ +public final class GrafanaGetByResourceGroupSamples { + /* + * x-ms-original-file: specification/dashboard/resource-manager/Microsoft.Dashboard/preview/2021-09-01-preview/examples/Grafana_Get.json + */ + /** + * Sample code: Grafana_Get. + * + * @param manager Entry point to DashboardManager. + */ + public static void grafanaGet(com.azure.resourcemanager.dashboard.DashboardManager manager) { + manager.grafanas().getByResourceGroupWithResponse("myResourceGroup", "myWorkspace", Context.NONE); + } +} +``` + +### Grafana_List + +```java +import com.azure.core.util.Context; + +/** Samples for Grafana List. */ +public final class GrafanaListSamples { + /* + * x-ms-original-file: specification/dashboard/resource-manager/Microsoft.Dashboard/preview/2021-09-01-preview/examples/Grafana_List.json + */ + /** + * Sample code: Grafana_List. + * + * @param manager Entry point to DashboardManager. + */ + public static void grafanaList(com.azure.resourcemanager.dashboard.DashboardManager manager) { + manager.grafanas().list(Context.NONE); + } +} +``` + +### Grafana_ListByResourceGroup + +```java +import com.azure.core.util.Context; + +/** Samples for Grafana ListByResourceGroup. */ +public final class GrafanaListByResourceGroupSamples { + /* + * x-ms-original-file: specification/dashboard/resource-manager/Microsoft.Dashboard/preview/2021-09-01-preview/examples/Grafana_ListByResourceGroup.json + */ + /** + * Sample code: Grafana_ListByResourceGroup. + * + * @param manager Entry point to DashboardManager. + */ + public static void grafanaListByResourceGroup(com.azure.resourcemanager.dashboard.DashboardManager manager) { + manager.grafanas().listByResourceGroup("myResourceGroup", Context.NONE); + } +} +``` + +### Grafana_Update + +```java +import com.azure.core.util.Context; +import com.azure.resourcemanager.dashboard.models.ManagedGrafana; +import java.util.HashMap; +import java.util.Map; + +/** Samples for Grafana Update. */ +public final class GrafanaUpdateSamples { + /* + * x-ms-original-file: specification/dashboard/resource-manager/Microsoft.Dashboard/preview/2021-09-01-preview/examples/Grafana_Update.json + */ + /** + * Sample code: Grafana_Update. + * + * @param manager Entry point to DashboardManager. + */ + public static void grafanaUpdate(com.azure.resourcemanager.dashboard.DashboardManager manager) { + ManagedGrafana resource = + manager + .grafanas() + .getByResourceGroupWithResponse("myResourceGroup", "myWorkspace", Context.NONE) + .getValue(); + resource.update().withTags(mapOf("Environment", "Dev 2")).apply(); + } + + @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; + } +} +``` + +### Operations_List + +```java +import com.azure.core.util.Context; + +/** Samples for Operations List. */ +public final class OperationsListSamples { + /* + * x-ms-original-file: specification/dashboard/resource-manager/Microsoft.Dashboard/preview/2021-09-01-preview/examples/Operations_List.json + */ + /** + * Sample code: Operations_List. + * + * @param manager Entry point to DashboardManager. + */ + public static void operationsList(com.azure.resourcemanager.dashboard.DashboardManager manager) { + manager.operations().list(Context.NONE); + } +} +``` + diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/pom.xml b/sdk/dashboard/azure-resourcemanager-dashboard/pom.xml new file mode 100644 index 0000000000000..341aba8753ee5 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/pom.xml @@ -0,0 +1,55 @@ + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure.resourcemanager + azure-resourcemanager-dashboard + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for Dashboard Management + This package contains Microsoft Azure SDK for Dashboard Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. The Microsoft.Dashboard Rest API spec. Package tag package-2021-09-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 + + + + com.azure + azure-core + 1.27.0 + + + com.azure + azure-core-management + 1.5.4 + + + diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/DashboardManager.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/DashboardManager.java new file mode 100644 index 0000000000000..5f55ba6a46868 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/DashboardManager.java @@ -0,0 +1,290 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.dashboard; + +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.http.policy.ArmChallengeAuthenticationPolicy; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.dashboard.fluent.DashboardManagementClient; +import com.azure.resourcemanager.dashboard.implementation.DashboardManagementClientBuilder; +import com.azure.resourcemanager.dashboard.implementation.GrafanasImpl; +import com.azure.resourcemanager.dashboard.implementation.OperationsImpl; +import com.azure.resourcemanager.dashboard.models.Grafanas; +import com.azure.resourcemanager.dashboard.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 DashboardManager. The Microsoft.Dashboard Rest API spec. */ +public final class DashboardManager { + private Operations operations; + + private Grafanas grafanas; + + private final DashboardManagementClient clientObject; + + private DashboardManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = + new DashboardManagementClientBuilder() + .pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of Dashboard service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Dashboard service API instance. + */ + public static DashboardManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return configure().authenticate(credential, profile); + } + + /** + * Creates an instance of Dashboard service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the Dashboard service API instance. + */ + public static DashboardManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new DashboardManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create DashboardManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new DashboardManager.Configurable(); + } + + /** The Configurable allowing configurations to be set. */ + public static final class Configurable { + private static final ClientLogger LOGGER = new ClientLogger(Configurable.class); + + private HttpClient httpClient; + private HttpLogOptions httpLogOptions; + private final List policies = new ArrayList<>(); + private final List scopes = new ArrayList<>(); + private RetryPolicy retryPolicy; + private RetryOptions retryOptions; + private Duration defaultPollInterval; + + private Configurable() { + } + + /** + * Sets the http client. + * + * @param httpClient the HTTP client. + * @return the configurable object itself. + */ + public Configurable withHttpClient(HttpClient httpClient) { + this.httpClient = Objects.requireNonNull(httpClient, "'httpClient' cannot be null."); + return this; + } + + /** + * Sets the logging options to the HTTP pipeline. + * + * @param httpLogOptions the HTTP log options. + * @return the configurable object itself. + */ + public Configurable withLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = Objects.requireNonNull(httpLogOptions, "'httpLogOptions' cannot be null."); + return this; + } + + /** + * Adds the pipeline policy to the HTTP pipeline. + * + * @param policy the HTTP pipeline policy. + * @return the configurable object itself. + */ + public Configurable withPolicy(HttpPipelinePolicy policy) { + this.policies.add(Objects.requireNonNull(policy, "'policy' cannot be null.")); + return this; + } + + /** + * Adds the scope to permission sets. + * + * @param scope the scope. + * @return the configurable object itself. + */ + public Configurable withScope(String scope) { + this.scopes.add(Objects.requireNonNull(scope, "'scope' cannot be null.")); + return this; + } + + /** + * Sets the retry policy to the HTTP pipeline. + * + * @param retryPolicy the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = Objects.requireNonNull(retryPolicy, "'retryPolicy' cannot be null."); + return this; + } + + /** + * Sets the retry options for the HTTP pipeline retry policy. + * + *

This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}. + * + * @param retryOptions the retry options for the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryOptions(RetryOptions retryOptions) { + this.retryOptions = Objects.requireNonNull(retryOptions, "'retryOptions' cannot be null."); + return this; + } + + /** + * Sets the default poll interval, used when service does not provide "Retry-After" header. + * + * @param defaultPollInterval the default poll interval. + * @return the configurable object itself. + */ + public Configurable withDefaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = + Objects.requireNonNull(defaultPollInterval, "'defaultPollInterval' cannot be null."); + if (this.defaultPollInterval.isNegative()) { + throw LOGGER + .logExceptionAsError(new IllegalArgumentException("'defaultPollInterval' cannot be negative")); + } + return this; + } + + /** + * Creates an instance of Dashboard service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Dashboard service API instance. + */ + public DashboardManager 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.dashboard") + .append("/") + .append("1.0.0-beta.1"); + if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) { + userAgentBuilder + .append(" (") + .append(Configuration.getGlobalConfiguration().get("java.version")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.name")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.version")) + .append("; auto-generated)"); + } else { + userAgentBuilder.append(" (auto-generated)"); + } + + if (scopes.isEmpty()) { + scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default"); + } + if (retryPolicy == null) { + if (retryOptions != null) { + retryPolicy = new RetryPolicy(retryOptions); + } else { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + } + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + policies.add(new AddHeadersFromContextPolicy()); + policies.add(new RequestIdPolicy()); + policies + .addAll( + this + .policies + .stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy); + policies.add(new AddDatePolicy()); + policies.add(new ArmChallengeAuthenticationPolicy(credential, scopes.toArray(new String[0]))); + policies + .addAll( + this + .policies + .stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = + new HttpPipelineBuilder() + .httpClient(httpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); + return new DashboardManager(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 Grafanas. */ + public Grafanas grafanas() { + if (this.grafanas == null) { + this.grafanas = new GrafanasImpl(clientObject.getGrafanas(), this); + } + return grafanas; + } + + /** + * @return Wrapped service client DashboardManagementClient providing direct access to the underlying auto-generated + * API implementation, based on Azure REST API. + */ + public DashboardManagementClient serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/DashboardManagementClient.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/DashboardManagementClient.java new file mode 100644 index 0000000000000..5b591b481b9b3 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/DashboardManagementClient.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.dashboard.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** The interface for DashboardManagementClient class. */ +public interface DashboardManagementClient { + /** + * Gets Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID + * forms part of the URI for every service call. + * + * @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 GrafanasClient object to access its operations. + * + * @return the GrafanasClient object. + */ + GrafanasClient getGrafanas(); +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/GrafanasClient.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/GrafanasClient.java new file mode 100644 index 0000000000000..47f5326be81b9 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/GrafanasClient.java @@ -0,0 +1,245 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.dashboard.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.dashboard.fluent.models.ManagedGrafanaInner; +import com.azure.resourcemanager.dashboard.models.ManagedGrafanaUpdateParameters; + +/** An instance of this class provides access to all the operations defined in GrafanasClient. */ +public interface GrafanasClient { + /** + * List all resources of workspaces for Grafana under the specified subscription. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * List all resources of workspaces for Grafana under the specified subscription. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); + + /** + * List all resources of workspaces for Grafana under the specified resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * List all resources of workspaces for Grafana under the specified resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Get the properties of a specific workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @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 properties of a specific workspace for Grafana resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ManagedGrafanaInner getByResourceGroup(String resourceGroupName, String workspaceName); + + /** + * Get the properties of a specific workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @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 properties of a specific workspace for Grafana resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse( + String resourceGroupName, String workspaceName, Context context); + + /** + * Create or update a workspace for Grafana resource. This API is idempotent, so user can either create a new + * grafana or update an existing grafana. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param requestBodyParameters The grafana resource type. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of the grafana resource type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, ManagedGrafanaInner> beginCreate( + String resourceGroupName, String workspaceName, ManagedGrafanaInner requestBodyParameters); + + /** + * Create or update a workspace for Grafana resource. This API is idempotent, so user can either create a new + * grafana or update an existing grafana. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param requestBodyParameters The grafana resource type. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of the grafana resource type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, ManagedGrafanaInner> beginCreate( + String resourceGroupName, String workspaceName, ManagedGrafanaInner requestBodyParameters, Context context); + + /** + * Create or update a workspace for Grafana resource. This API is idempotent, so user can either create a new + * grafana or update an existing grafana. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param requestBodyParameters The grafana resource type. + * @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 grafana resource type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ManagedGrafanaInner create( + String resourceGroupName, String workspaceName, ManagedGrafanaInner requestBodyParameters); + + /** + * Create or update a workspace for Grafana resource. This API is idempotent, so user can either create a new + * grafana or update an existing grafana. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param requestBodyParameters The grafana resource type. + * @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 grafana resource type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ManagedGrafanaInner create( + String resourceGroupName, String workspaceName, ManagedGrafanaInner requestBodyParameters, Context context); + + /** + * Update a workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param requestBodyParameters The parameters for a PATCH request to a grafana resource. + * @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 grafana resource type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ManagedGrafanaInner update( + String resourceGroupName, String workspaceName, ManagedGrafanaUpdateParameters requestBodyParameters); + + /** + * Update a workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param requestBodyParameters The parameters for a PATCH request to a grafana 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 the grafana resource type along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response updateWithResponse( + String resourceGroupName, + String workspaceName, + ManagedGrafanaUpdateParameters requestBodyParameters, + Context context); + + /** + * Delete a workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String workspaceName); + + /** + * Delete a workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String workspaceName, Context context); + + /** + * Delete a workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @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 workspaceName); + + /** + * Delete a workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @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 workspaceName, Context context); +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/OperationsClient.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/OperationsClient.java new file mode 100644 index 0000000000000..990b0d5d43e7b --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/OperationsClient.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.dashboard.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.dashboard.fluent.models.OperationResultInner; + +/** An instance of this class provides access to all the operations defined in OperationsClient. */ +public interface OperationsClient { + /** + * List all available API operations provided by Microsoft.Dashboard. + * + * @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 Microsoft.Dashboard provider as paginated response with {@link + * PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * List all available API operations provided by Microsoft.Dashboard. + * + * @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 Microsoft.Dashboard provider as paginated response with {@link + * PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/models/ManagedGrafanaInner.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/models/ManagedGrafanaInner.java new file mode 100644 index 0000000000000..fcb394255caf9 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/models/ManagedGrafanaInner.java @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.dashboard.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.azure.resourcemanager.dashboard.models.ManagedGrafanaProperties; +import com.azure.resourcemanager.dashboard.models.ManagedIdentity; +import com.azure.resourcemanager.dashboard.models.ResourceSku; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + +/** The grafana resource type. */ +@Fluent +public final class ManagedGrafanaInner extends Resource { + /* + * The Sku of the grafana resource. + */ + @JsonProperty(value = "sku") + private ResourceSku sku; + + /* + * Properties specific to the grafana resource. + */ + @JsonProperty(value = "properties") + private ManagedGrafanaProperties properties; + + /* + * The managed identity of the grafana resource. + */ + @JsonProperty(value = "identity") + private ManagedIdentity identity; + + /* + * The system meta data relating to this grafana resource. + */ + @JsonProperty(value = "systemData", access = JsonProperty.Access.WRITE_ONLY) + private SystemData systemData; + + /** + * Get the sku property: The Sku of the grafana resource. + * + * @return the sku value. + */ + public ResourceSku sku() { + return this.sku; + } + + /** + * Set the sku property: The Sku of the grafana resource. + * + * @param sku the sku value to set. + * @return the ManagedGrafanaInner object itself. + */ + public ManagedGrafanaInner withSku(ResourceSku sku) { + this.sku = sku; + return this; + } + + /** + * Get the properties property: Properties specific to the grafana resource. + * + * @return the properties value. + */ + public ManagedGrafanaProperties properties() { + return this.properties; + } + + /** + * Set the properties property: Properties specific to the grafana resource. + * + * @param properties the properties value to set. + * @return the ManagedGrafanaInner object itself. + */ + public ManagedGrafanaInner withProperties(ManagedGrafanaProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the identity property: The managed identity of the grafana resource. + * + * @return the identity value. + */ + public ManagedIdentity identity() { + return this.identity; + } + + /** + * Set the identity property: The managed identity of the grafana resource. + * + * @param identity the identity value to set. + * @return the ManagedGrafanaInner object itself. + */ + public ManagedGrafanaInner withIdentity(ManagedIdentity identity) { + this.identity = identity; + return this; + } + + /** + * Get the systemData property: The system meta data relating to this grafana resource. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** {@inheritDoc} */ + @Override + public ManagedGrafanaInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** {@inheritDoc} */ + @Override + public ManagedGrafanaInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (sku() != null) { + sku().validate(); + } + if (properties() != null) { + properties().validate(); + } + if (identity() != null) { + identity().validate(); + } + } +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/models/OperationResultInner.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/models/OperationResultInner.java new file mode 100644 index 0000000000000..b5e3cb59a1ca3 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/models/OperationResultInner.java @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.dashboard.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.resourcemanager.dashboard.models.ActionType; +import com.azure.resourcemanager.dashboard.models.OperationDisplay; +import com.azure.resourcemanager.dashboard.models.Origin; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** A Microsoft.Dashboard REST API operation. */ +@Fluent +public final class OperationResultInner { + /* + * Operation name, i.e., {provider}/{resource}/{operation}. + */ + @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /* + * Indicates whether the operation applies to data-plane. Set "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. + */ + @JsonProperty(value = "origin", access = JsonProperty.Access.WRITE_ONLY) + private Origin origin; + + /* + * 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: Operation name, i.e., {provider}/{resource}/{operation}. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Get the isDataAction property: Indicates whether the operation applies to data-plane. Set "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 OperationResultInner object itself. + */ + public OperationResultInner withDisplay(OperationDisplay display) { + this.display = display; + return this; + } + + /** + * Get the origin property: The intended executor of the operation. + * + * @return the origin value. + */ + public Origin origin() { + return this.origin; + } + + /** + * Get the actionType property: 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/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/models/package-info.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/models/package-info.java new file mode 100644 index 0000000000000..1626ded177366 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/models/package-info.java @@ -0,0 +1,6 @@ +// 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 DashboardManagementClient. The Microsoft.Dashboard Rest API spec. */ +package com.azure.resourcemanager.dashboard.fluent.models; diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/package-info.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/package-info.java new file mode 100644 index 0000000000000..f8b8bc93ed550 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/fluent/package-info.java @@ -0,0 +1,6 @@ +// 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 DashboardManagementClient. The Microsoft.Dashboard Rest API spec. */ +package com.azure.resourcemanager.dashboard.fluent; diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/DashboardManagementClientBuilder.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/DashboardManagementClientBuilder.java new file mode 100644 index 0000000000000..c5af019139b04 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/DashboardManagementClientBuilder.java @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.dashboard.implementation; + +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerAdapter; +import java.time.Duration; + +/** A builder for creating a new instance of the DashboardManagementClientImpl type. */ +@ServiceClientBuilder(serviceClients = {DashboardManagementClientImpl.class}) +public final class DashboardManagementClientBuilder { + /* + * Gets subscription credentials which uniquely identify Microsoft Azure + * subscription. The subscription ID forms part of the URI for every + * service call. + */ + private String subscriptionId; + + /** + * Sets Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID + * forms part of the URI for every service call. + * + * @param subscriptionId the subscriptionId value. + * @return the DashboardManagementClientBuilder. + */ + public DashboardManagementClientBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * server parameter + */ + private String endpoint; + + /** + * Sets server parameter. + * + * @param endpoint the endpoint value. + * @return the DashboardManagementClientBuilder. + */ + public DashboardManagementClientBuilder 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 DashboardManagementClientBuilder. + */ + public DashboardManagementClientBuilder environment(AzureEnvironment environment) { + this.environment = environment; + return this; + } + + /* + * The HTTP pipeline to send requests through + */ + private HttpPipeline pipeline; + + /** + * Sets The HTTP pipeline to send requests through. + * + * @param pipeline the pipeline value. + * @return the DashboardManagementClientBuilder. + */ + public DashboardManagementClientBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /* + * The default poll interval for long-running operation + */ + private Duration defaultPollInterval; + + /** + * Sets The default poll interval for long-running operation. + * + * @param defaultPollInterval the defaultPollInterval value. + * @return the DashboardManagementClientBuilder. + */ + public DashboardManagementClientBuilder defaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = defaultPollInterval; + return this; + } + + /* + * The serializer to serialize an object into a string + */ + private SerializerAdapter serializerAdapter; + + /** + * Sets The serializer to serialize an object into a string. + * + * @param serializerAdapter the serializerAdapter value. + * @return the DashboardManagementClientBuilder. + */ + public DashboardManagementClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of DashboardManagementClientImpl with the provided parameters. + * + * @return an instance of DashboardManagementClientImpl. + */ + public DashboardManagementClientImpl buildClient() { + if (pipeline == null) { + this.pipeline = new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(); + } + if (endpoint == null) { + this.endpoint = ""; + } + if (environment == null) { + this.environment = AzureEnvironment.AZURE; + } + if (pipeline == null) { + this.pipeline = new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(); + } + if (defaultPollInterval == null) { + this.defaultPollInterval = Duration.ofSeconds(30); + } + if (serializerAdapter == null) { + this.serializerAdapter = SerializerFactory.createDefaultManagementSerializerAdapter(); + } + DashboardManagementClientImpl client = + new DashboardManagementClientImpl( + pipeline, serializerAdapter, defaultPollInterval, environment, subscriptionId, endpoint); + return client; + } +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/DashboardManagementClientImpl.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/DashboardManagementClientImpl.java new file mode 100644 index 0000000000000..78060d7d83c0b --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/DashboardManagementClientImpl.java @@ -0,0 +1,312 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.dashboard.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.dashboard.fluent.DashboardManagementClient; +import com.azure.resourcemanager.dashboard.fluent.GrafanasClient; +import com.azure.resourcemanager.dashboard.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 DashboardManagementClientImpl type. */ +@ServiceClient(builder = DashboardManagementClientBuilder.class) +public final class DashboardManagementClientImpl implements DashboardManagementClient { + /** + * Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms + * part of the URI for every service call. + */ + private final String subscriptionId; + + /** + * Gets Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID + * forms part of the URI for every service call. + * + * @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 GrafanasClient object to access its operations. */ + private final GrafanasClient grafanas; + + /** + * Gets the GrafanasClient object to access its operations. + * + * @return the GrafanasClient object. + */ + public GrafanasClient getGrafanas() { + return this.grafanas; + } + + /** + * Initializes an instance of DashboardManagementClient 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 Gets subscription credentials which uniquely identify Microsoft Azure subscription. The + * subscription ID forms part of the URI for every service call. + * @param endpoint server parameter. + */ + DashboardManagementClientImpl( + 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-09-01-preview"; + this.operations = new OperationsClientImpl(this); + this.grafanas = new GrafanasClientImpl(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)); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(DashboardManagementClientImpl.class); +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/GrafanasClientImpl.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/GrafanasClientImpl.java new file mode 100644 index 0000000000000..8d57ce3cfbe50 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/GrafanasClientImpl.java @@ -0,0 +1,1453 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.dashboard.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.dashboard.fluent.GrafanasClient; +import com.azure.resourcemanager.dashboard.fluent.models.ManagedGrafanaInner; +import com.azure.resourcemanager.dashboard.models.ManagedGrafanaListResponse; +import com.azure.resourcemanager.dashboard.models.ManagedGrafanaUpdateParameters; +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 GrafanasClient. */ +public final class GrafanasClientImpl implements GrafanasClient { + /** The proxy service used to perform REST calls. */ + private final GrafanasService service; + + /** The service client containing this operation class. */ + private final DashboardManagementClientImpl client; + + /** + * Initializes an instance of GrafanasClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + GrafanasClientImpl(DashboardManagementClientImpl client) { + this.service = RestProxy.create(GrafanasService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DashboardManagementClientGrafanas to be used by the proxy service to + * perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "DashboardManagementC") + private interface GrafanasService { + @Headers({"Content-Type: application/json"}) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Dashboard/grafana") + @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.Dashboard/grafana") + @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.Dashboard/grafana" + + "/{workspaceName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("workspaceName") String workspaceName, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Put( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana" + + "/{workspaceName}") + @ExpectedResponses({200, 201}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> create( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("workspaceName") String workspaceName, + @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") ManagedGrafanaInner requestBodyParameters, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Patch( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana" + + "/{workspaceName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> update( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("workspaceName") String workspaceName, + @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") ManagedGrafanaUpdateParameters requestBodyParameters, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Delete( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana" + + "/{workspaceName}") + @ExpectedResponses({200, 202, 204}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> delete( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("workspaceName") String workspaceName, + @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); + + @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); + } + + /** + * List all resources of workspaces for Grafana under the specified subscription. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync() { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .list( + this.client.getEndpoint(), + this.client.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())); + } + + /** + * List all resources of workspaces for Grafana under the specified subscription. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .list( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + this.client.getApiVersion(), + accept, + context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * List all resources of workspaces for Grafana under the specified subscription. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * List all resources of workspaces for Grafana under the specified subscription. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(context), nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * List all resources of workspaces for Grafana under the specified subscription. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * List all resources of workspaces for Grafana under the specified subscription. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * List all resources of workspaces for Grafana under the specified resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupSinglePageAsync(String resourceGroupName) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .listByResourceGroup( + this.client.getEndpoint(), + this.client.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())); + } + + /** + * List all resources of workspaces for Grafana under the specified resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupSinglePageAsync( + String resourceGroupName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByResourceGroup( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + this.client.getApiVersion(), + accept, + context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * List all resources of workspaces for Grafana under the specified resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName) { + return new PagedFlux<>( + () -> listByResourceGroupSinglePageAsync(resourceGroupName), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink)); + } + + /** + * List all resources of workspaces for Grafana under the specified resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName, Context context) { + return new PagedFlux<>( + () -> listByResourceGroupSinglePageAsync(resourceGroupName, context), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink, context)); + } + + /** + * List all resources of workspaces for Grafana under the specified resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName)); + } + + /** + * List all resources of workspaces for Grafana under the specified resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context)); + } + + /** + * Get the properties of a specific workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @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 properties of a specific workspace for Grafana resource along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync( + String resourceGroupName, String workspaceName) { + 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 (workspaceName == null) { + return Mono.error(new IllegalArgumentException("Parameter workspaceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .getByResourceGroup( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + workspaceName, + this.client.getApiVersion(), + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the properties of a specific workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @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 properties of a specific workspace for Grafana resource along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync( + String resourceGroupName, String workspaceName, 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 (workspaceName == null) { + return Mono.error(new IllegalArgumentException("Parameter workspaceName 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, + workspaceName, + this.client.getApiVersion(), + accept, + context); + } + + /** + * Get the properties of a specific workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @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 properties of a specific workspace for Grafana resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, String workspaceName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, workspaceName) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Get the properties of a specific workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @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 properties of a specific workspace for Grafana resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ManagedGrafanaInner getByResourceGroup(String resourceGroupName, String workspaceName) { + return getByResourceGroupAsync(resourceGroupName, workspaceName).block(); + } + + /** + * Get the properties of a specific workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @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 properties of a specific workspace for Grafana resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse( + String resourceGroupName, String workspaceName, Context context) { + return getByResourceGroupWithResponseAsync(resourceGroupName, workspaceName, context).block(); + } + + /** + * Create or update a workspace for Grafana resource. This API is idempotent, so user can either create a new + * grafana or update an existing grafana. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param requestBodyParameters The grafana resource type. + * @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 grafana resource type along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createWithResponseAsync( + String resourceGroupName, String workspaceName, ManagedGrafanaInner requestBodyParameters) { + 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 (workspaceName == null) { + return Mono.error(new IllegalArgumentException("Parameter workspaceName is required and cannot be null.")); + } + if (requestBodyParameters == null) { + return Mono + .error(new IllegalArgumentException("Parameter requestBodyParameters is required and cannot be null.")); + } else { + requestBodyParameters.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .create( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + workspaceName, + this.client.getApiVersion(), + requestBodyParameters, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create or update a workspace for Grafana resource. This API is idempotent, so user can either create a new + * grafana or update an existing grafana. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param requestBodyParameters The grafana resource type. + * @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 grafana resource type along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createWithResponseAsync( + String resourceGroupName, String workspaceName, ManagedGrafanaInner requestBodyParameters, 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 (workspaceName == null) { + return Mono.error(new IllegalArgumentException("Parameter workspaceName is required and cannot be null.")); + } + if (requestBodyParameters == null) { + return Mono + .error(new IllegalArgumentException("Parameter requestBodyParameters is required and cannot be null.")); + } else { + requestBodyParameters.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .create( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + workspaceName, + this.client.getApiVersion(), + requestBodyParameters, + accept, + context); + } + + /** + * Create or update a workspace for Grafana resource. This API is idempotent, so user can either create a new + * grafana or update an existing grafana. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param requestBodyParameters The grafana resource type. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of the grafana resource type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, ManagedGrafanaInner> beginCreateAsync( + String resourceGroupName, String workspaceName, ManagedGrafanaInner requestBodyParameters) { + Mono>> mono = + createWithResponseAsync(resourceGroupName, workspaceName, requestBodyParameters); + return this + .client + .getLroResult( + mono, + this.client.getHttpPipeline(), + ManagedGrafanaInner.class, + ManagedGrafanaInner.class, + this.client.getContext()); + } + + /** + * Create or update a workspace for Grafana resource. This API is idempotent, so user can either create a new + * grafana or update an existing grafana. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param requestBodyParameters The grafana resource type. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of the grafana resource type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, ManagedGrafanaInner> beginCreateAsync( + String resourceGroupName, String workspaceName, ManagedGrafanaInner requestBodyParameters, Context context) { + context = this.client.mergeContext(context); + Mono>> mono = + createWithResponseAsync(resourceGroupName, workspaceName, requestBodyParameters, context); + return this + .client + .getLroResult( + mono, this.client.getHttpPipeline(), ManagedGrafanaInner.class, ManagedGrafanaInner.class, context); + } + + /** + * Create or update a workspace for Grafana resource. This API is idempotent, so user can either create a new + * grafana or update an existing grafana. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param requestBodyParameters The grafana resource type. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of the grafana resource type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, ManagedGrafanaInner> beginCreate( + String resourceGroupName, String workspaceName, ManagedGrafanaInner requestBodyParameters) { + return beginCreateAsync(resourceGroupName, workspaceName, requestBodyParameters).getSyncPoller(); + } + + /** + * Create or update a workspace for Grafana resource. This API is idempotent, so user can either create a new + * grafana or update an existing grafana. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param requestBodyParameters The grafana resource type. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of the grafana resource type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, ManagedGrafanaInner> beginCreate( + String resourceGroupName, String workspaceName, ManagedGrafanaInner requestBodyParameters, Context context) { + return beginCreateAsync(resourceGroupName, workspaceName, requestBodyParameters, context).getSyncPoller(); + } + + /** + * Create or update a workspace for Grafana resource. This API is idempotent, so user can either create a new + * grafana or update an existing grafana. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param requestBodyParameters The grafana resource type. + * @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 grafana resource type on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createAsync( + String resourceGroupName, String workspaceName, ManagedGrafanaInner requestBodyParameters) { + return beginCreateAsync(resourceGroupName, workspaceName, requestBodyParameters) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create or update a workspace for Grafana resource. This API is idempotent, so user can either create a new + * grafana or update an existing grafana. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param requestBodyParameters The grafana resource type. + * @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 grafana resource type on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createAsync( + String resourceGroupName, String workspaceName, ManagedGrafanaInner requestBodyParameters, Context context) { + return beginCreateAsync(resourceGroupName, workspaceName, requestBodyParameters, context) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create or update a workspace for Grafana resource. This API is idempotent, so user can either create a new + * grafana or update an existing grafana. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param requestBodyParameters The grafana resource type. + * @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 grafana resource type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ManagedGrafanaInner create( + String resourceGroupName, String workspaceName, ManagedGrafanaInner requestBodyParameters) { + return createAsync(resourceGroupName, workspaceName, requestBodyParameters).block(); + } + + /** + * Create or update a workspace for Grafana resource. This API is idempotent, so user can either create a new + * grafana or update an existing grafana. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param requestBodyParameters The grafana resource type. + * @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 grafana resource type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ManagedGrafanaInner create( + String resourceGroupName, String workspaceName, ManagedGrafanaInner requestBodyParameters, Context context) { + return createAsync(resourceGroupName, workspaceName, requestBodyParameters, context).block(); + } + + /** + * Update a workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param requestBodyParameters The parameters for a PATCH request to a grafana resource. + * @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 grafana resource type along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync( + String resourceGroupName, String workspaceName, ManagedGrafanaUpdateParameters requestBodyParameters) { + 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 (workspaceName == null) { + return Mono.error(new IllegalArgumentException("Parameter workspaceName is required and cannot be null.")); + } + if (requestBodyParameters == null) { + return Mono + .error(new IllegalArgumentException("Parameter requestBodyParameters is required and cannot be null.")); + } else { + requestBodyParameters.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .update( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + workspaceName, + this.client.getApiVersion(), + requestBodyParameters, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update a workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param requestBodyParameters The parameters for a PATCH request to a grafana 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 the grafana resource type along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync( + String resourceGroupName, + String workspaceName, + ManagedGrafanaUpdateParameters requestBodyParameters, + 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 (workspaceName == null) { + return Mono.error(new IllegalArgumentException("Parameter workspaceName is required and cannot be null.")); + } + if (requestBodyParameters == null) { + return Mono + .error(new IllegalArgumentException("Parameter requestBodyParameters is required and cannot be null.")); + } else { + requestBodyParameters.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .update( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + workspaceName, + this.client.getApiVersion(), + requestBodyParameters, + accept, + context); + } + + /** + * Update a workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param requestBodyParameters The parameters for a PATCH request to a grafana resource. + * @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 grafana resource type on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync( + String resourceGroupName, String workspaceName, ManagedGrafanaUpdateParameters requestBodyParameters) { + return updateWithResponseAsync(resourceGroupName, workspaceName, requestBodyParameters) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Update a workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param requestBodyParameters The parameters for a PATCH request to a grafana resource. + * @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 grafana resource type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ManagedGrafanaInner update( + String resourceGroupName, String workspaceName, ManagedGrafanaUpdateParameters requestBodyParameters) { + return updateAsync(resourceGroupName, workspaceName, requestBodyParameters).block(); + } + + /** + * Update a workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param requestBodyParameters The parameters for a PATCH request to a grafana 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 the grafana resource type along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateWithResponse( + String resourceGroupName, + String workspaceName, + ManagedGrafanaUpdateParameters requestBodyParameters, + Context context) { + return updateWithResponseAsync(resourceGroupName, workspaceName, requestBodyParameters, context).block(); + } + + /** + * Delete a workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> deleteWithResponseAsync(String resourceGroupName, String workspaceName) { + 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 (workspaceName == null) { + return Mono.error(new IllegalArgumentException("Parameter workspaceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .delete( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + workspaceName, + this.client.getApiVersion(), + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> deleteWithResponseAsync( + String resourceGroupName, String workspaceName, 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 (workspaceName == null) { + return Mono.error(new IllegalArgumentException("Parameter workspaceName 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, + workspaceName, + this.client.getApiVersion(), + accept, + context); + } + + /** + * Delete a workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, String workspaceName) { + Mono>> mono = deleteWithResponseAsync(resourceGroupName, workspaceName); + return this + .client + .getLroResult( + mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext()); + } + + /** + * Delete a workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync( + String resourceGroupName, String workspaceName, Context context) { + context = this.client.mergeContext(context); + Mono>> mono = deleteWithResponseAsync(resourceGroupName, workspaceName, context); + return this + .client + .getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context); + } + + /** + * Delete a workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, String workspaceName) { + return beginDeleteAsync(resourceGroupName, workspaceName).getSyncPoller(); + } + + /** + * Delete a workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete( + String resourceGroupName, String workspaceName, Context context) { + return beginDeleteAsync(resourceGroupName, workspaceName, context).getSyncPoller(); + } + + /** + * Delete a workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String workspaceName) { + return beginDeleteAsync(resourceGroupName, workspaceName).last().flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String workspaceName, Context context) { + return beginDeleteAsync(resourceGroupName, workspaceName, context) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @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 workspaceName) { + deleteAsync(resourceGroupName, workspaceName).block(); + } + + /** + * Delete a workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @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 workspaceName, Context context) { + deleteAsync(resourceGroupName, workspaceName, 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 the response body along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The 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 the response body along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listNext(nextLink, this.client.getEndpoint(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * 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 the response body along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listByResourceGroupNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The 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 the response body along with {@link PagedResponse} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupNextSinglePageAsync( + String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByResourceGroupNext(nextLink, this.client.getEndpoint(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/GrafanasImpl.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/GrafanasImpl.java new file mode 100644 index 0000000000000..c6a4cba504e95 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/GrafanasImpl.java @@ -0,0 +1,169 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.dashboard.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.dashboard.fluent.GrafanasClient; +import com.azure.resourcemanager.dashboard.fluent.models.ManagedGrafanaInner; +import com.azure.resourcemanager.dashboard.models.Grafanas; +import com.azure.resourcemanager.dashboard.models.ManagedGrafana; + +public final class GrafanasImpl implements Grafanas { + private static final ClientLogger LOGGER = new ClientLogger(GrafanasImpl.class); + + private final GrafanasClient innerClient; + + private final com.azure.resourcemanager.dashboard.DashboardManager serviceManager; + + public GrafanasImpl( + GrafanasClient innerClient, com.azure.resourcemanager.dashboard.DashboardManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return Utils.mapPage(inner, inner1 -> new ManagedGrafanaImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return Utils.mapPage(inner, inner1 -> new ManagedGrafanaImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName); + return Utils.mapPage(inner, inner1 -> new ManagedGrafanaImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName, context); + return Utils.mapPage(inner, inner1 -> new ManagedGrafanaImpl(inner1, this.manager())); + } + + public ManagedGrafana getByResourceGroup(String resourceGroupName, String workspaceName) { + ManagedGrafanaInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, workspaceName); + if (inner != null) { + return new ManagedGrafanaImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response getByResourceGroupWithResponse( + String resourceGroupName, String workspaceName, Context context) { + Response inner = + this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, workspaceName, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new ManagedGrafanaImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public void deleteByResourceGroup(String resourceGroupName, String workspaceName) { + this.serviceClient().delete(resourceGroupName, workspaceName); + } + + public void delete(String resourceGroupName, String workspaceName, Context context) { + this.serviceClient().delete(resourceGroupName, workspaceName, context); + } + + public ManagedGrafana 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 workspaceName = Utils.getValueFromIdByName(id, "grafana"); + if (workspaceName == null) { + throw LOGGER + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'grafana'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, workspaceName, 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 workspaceName = Utils.getValueFromIdByName(id, "grafana"); + if (workspaceName == null) { + throw LOGGER + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'grafana'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, workspaceName, 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 workspaceName = Utils.getValueFromIdByName(id, "grafana"); + if (workspaceName == null) { + throw LOGGER + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'grafana'.", id))); + } + this.delete(resourceGroupName, workspaceName, 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 workspaceName = Utils.getValueFromIdByName(id, "grafana"); + if (workspaceName == null) { + throw LOGGER + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'grafana'.", id))); + } + this.delete(resourceGroupName, workspaceName, context); + } + + private GrafanasClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.dashboard.DashboardManager manager() { + return this.serviceManager; + } + + public ManagedGrafanaImpl define(String name) { + return new ManagedGrafanaImpl(name, this.manager()); + } +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/ManagedGrafanaImpl.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/ManagedGrafanaImpl.java new file mode 100644 index 0000000000000..fd1cca146e6cc --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/ManagedGrafanaImpl.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.dashboard.implementation; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.dashboard.fluent.models.ManagedGrafanaInner; +import com.azure.resourcemanager.dashboard.models.ManagedGrafana; +import com.azure.resourcemanager.dashboard.models.ManagedGrafanaProperties; +import com.azure.resourcemanager.dashboard.models.ManagedGrafanaUpdateParameters; +import com.azure.resourcemanager.dashboard.models.ManagedIdentity; +import com.azure.resourcemanager.dashboard.models.ResourceSku; +import java.util.Collections; +import java.util.Map; + +public final class ManagedGrafanaImpl implements ManagedGrafana, ManagedGrafana.Definition, ManagedGrafana.Update { + private ManagedGrafanaInner innerObject; + + private final com.azure.resourcemanager.dashboard.DashboardManager 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 ResourceSku sku() { + return this.innerModel().sku(); + } + + public ManagedGrafanaProperties properties() { + return this.innerModel().properties(); + } + + public ManagedIdentity identity() { + return this.innerModel().identity(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public ManagedGrafanaInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.dashboard.DashboardManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String workspaceName; + + private ManagedGrafanaUpdateParameters updateRequestBodyParameters; + + public ManagedGrafanaImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public ManagedGrafana create() { + this.innerObject = + serviceManager + .serviceClient() + .getGrafanas() + .create(resourceGroupName, workspaceName, this.innerModel(), Context.NONE); + return this; + } + + public ManagedGrafana create(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getGrafanas() + .create(resourceGroupName, workspaceName, this.innerModel(), context); + return this; + } + + ManagedGrafanaImpl(String name, com.azure.resourcemanager.dashboard.DashboardManager serviceManager) { + this.innerObject = new ManagedGrafanaInner(); + this.serviceManager = serviceManager; + this.workspaceName = name; + } + + public ManagedGrafanaImpl update() { + this.updateRequestBodyParameters = new ManagedGrafanaUpdateParameters(); + return this; + } + + public ManagedGrafana apply() { + this.innerObject = + serviceManager + .serviceClient() + .getGrafanas() + .updateWithResponse(resourceGroupName, workspaceName, updateRequestBodyParameters, Context.NONE) + .getValue(); + return this; + } + + public ManagedGrafana apply(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getGrafanas() + .updateWithResponse(resourceGroupName, workspaceName, updateRequestBodyParameters, context) + .getValue(); + return this; + } + + ManagedGrafanaImpl( + ManagedGrafanaInner innerObject, com.azure.resourcemanager.dashboard.DashboardManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = Utils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.workspaceName = Utils.getValueFromIdByName(innerObject.id(), "grafana"); + } + + public ManagedGrafana refresh() { + this.innerObject = + serviceManager + .serviceClient() + .getGrafanas() + .getByResourceGroupWithResponse(resourceGroupName, workspaceName, Context.NONE) + .getValue(); + return this; + } + + public ManagedGrafana refresh(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getGrafanas() + .getByResourceGroupWithResponse(resourceGroupName, workspaceName, context) + .getValue(); + return this; + } + + public ManagedGrafanaImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public ManagedGrafanaImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public ManagedGrafanaImpl withTags(Map tags) { + if (isInCreateMode()) { + this.innerModel().withTags(tags); + return this; + } else { + this.updateRequestBodyParameters.withTags(tags); + return this; + } + } + + public ManagedGrafanaImpl withSku(ResourceSku sku) { + this.innerModel().withSku(sku); + return this; + } + + public ManagedGrafanaImpl withProperties(ManagedGrafanaProperties properties) { + this.innerModel().withProperties(properties); + return this; + } + + public ManagedGrafanaImpl withIdentity(ManagedIdentity identity) { + if (isInCreateMode()) { + this.innerModel().withIdentity(identity); + return this; + } else { + this.updateRequestBodyParameters.withIdentity(identity); + return this; + } + } + + private boolean isInCreateMode() { + return this.innerModel().id() == null; + } +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/OperationResultImpl.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/OperationResultImpl.java new file mode 100644 index 0000000000000..e8caf4ea66e51 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/OperationResultImpl.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.dashboard.implementation; + +import com.azure.resourcemanager.dashboard.fluent.models.OperationResultInner; +import com.azure.resourcemanager.dashboard.models.ActionType; +import com.azure.resourcemanager.dashboard.models.OperationDisplay; +import com.azure.resourcemanager.dashboard.models.OperationResult; +import com.azure.resourcemanager.dashboard.models.Origin; + +public final class OperationResultImpl implements OperationResult { + private OperationResultInner innerObject; + + private final com.azure.resourcemanager.dashboard.DashboardManager serviceManager; + + OperationResultImpl( + OperationResultInner innerObject, com.azure.resourcemanager.dashboard.DashboardManager 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 OperationResultInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.dashboard.DashboardManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/OperationsClientImpl.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/OperationsClientImpl.java new file mode 100644 index 0000000000000..2e6a14df38514 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/OperationsClientImpl.java @@ -0,0 +1,274 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.dashboard.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.resourcemanager.dashboard.fluent.OperationsClient; +import com.azure.resourcemanager.dashboard.fluent.models.OperationResultInner; +import com.azure.resourcemanager.dashboard.models.OperationListResult; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in OperationsClient. */ +public final class OperationsClientImpl implements OperationsClient { + /** The proxy service used to perform REST calls. */ + private final OperationsService service; + + /** The service client containing this operation class. */ + private final DashboardManagementClientImpl client; + + /** + * Initializes an instance of OperationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationsClientImpl(DashboardManagementClientImpl client) { + this.service = + RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DashboardManagementClientOperations to be used by the proxy service + * to perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "DashboardManagementC") + private interface OperationsService { + @Headers({"Content-Type: application/json"}) + @Get("/providers/Microsoft.Dashboard/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); + } + + /** + * List all available API operations provided by Microsoft.Dashboard. + * + * @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 Microsoft.Dashboard provider along with {@link PagedResponse} + * on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync() { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List all available API operations provided by Microsoft.Dashboard. + * + * @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 Microsoft.Dashboard provider along with {@link PagedResponse} + * on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * List all available API operations provided by Microsoft.Dashboard. + * + * @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 Microsoft.Dashboard provider as paginated response with {@link + * PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * List all available API operations provided by Microsoft.Dashboard. + * + * @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 Microsoft.Dashboard provider as paginated response with {@link + * PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(context), nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * List all available API operations provided by Microsoft.Dashboard. + * + * @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 Microsoft.Dashboard provider as paginated response with {@link + * PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * List all available API operations provided by Microsoft.Dashboard. + * + * @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 Microsoft.Dashboard provider as paginated response with {@link + * PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The 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 Microsoft.Dashboard provider along with {@link PagedResponse} + * on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The 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 Microsoft.Dashboard provider along with {@link PagedResponse} + * on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listNext(nextLink, this.client.getEndpoint(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/OperationsImpl.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/OperationsImpl.java new file mode 100644 index 0000000000000..9d766e2b1775b --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/OperationsImpl.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.dashboard.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.dashboard.fluent.OperationsClient; +import com.azure.resourcemanager.dashboard.fluent.models.OperationResultInner; +import com.azure.resourcemanager.dashboard.models.OperationResult; +import com.azure.resourcemanager.dashboard.models.Operations; + +public final class OperationsImpl implements Operations { + private static final ClientLogger LOGGER = new ClientLogger(OperationsImpl.class); + + private final OperationsClient innerClient; + + private final com.azure.resourcemanager.dashboard.DashboardManager serviceManager; + + public OperationsImpl( + OperationsClient innerClient, com.azure.resourcemanager.dashboard.DashboardManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return Utils.mapPage(inner, inner1 -> new OperationResultImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return Utils.mapPage(inner, inner1 -> new OperationResultImpl(inner1, this.manager())); + } + + private OperationsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.dashboard.DashboardManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/Utils.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/Utils.java new file mode 100644 index 0000000000000..a1247617ced49 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/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.dashboard.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/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/package-info.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/package-info.java new file mode 100644 index 0000000000000..01962e432f56f --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/implementation/package-info.java @@ -0,0 +1,6 @@ +// 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 DashboardManagementClient. The Microsoft.Dashboard Rest API spec. */ +package com.azure.resourcemanager.dashboard.implementation; diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ActionType.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ActionType.java new file mode 100644 index 0000000000000..bd00af77d5d81 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/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.dashboard.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/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/AutoGeneratedDomainNameLabelScope.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/AutoGeneratedDomainNameLabelScope.java new file mode 100644 index 0000000000000..aa81e76962c46 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/AutoGeneratedDomainNameLabelScope.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.dashboard.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for AutoGeneratedDomainNameLabelScope. */ +public final class AutoGeneratedDomainNameLabelScope extends ExpandableStringEnum { + /** Static value TenantReuse for AutoGeneratedDomainNameLabelScope. */ + public static final AutoGeneratedDomainNameLabelScope TENANT_REUSE = fromString("TenantReuse"); + + /** + * Creates or finds a AutoGeneratedDomainNameLabelScope from its string representation. + * + * @param name a name to look for. + * @return the corresponding AutoGeneratedDomainNameLabelScope. + */ + @JsonCreator + public static AutoGeneratedDomainNameLabelScope fromString(String name) { + return fromString(name, AutoGeneratedDomainNameLabelScope.class); + } + + /** @return known AutoGeneratedDomainNameLabelScope values. */ + public static Collection values() { + return values(AutoGeneratedDomainNameLabelScope.class); + } +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/Grafanas.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/Grafanas.java new file mode 100644 index 0000000000000..f445725274e98 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/Grafanas.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.dashboard.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 Grafanas. */ +public interface Grafanas { + /** + * List all resources of workspaces for Grafana under the specified subscription. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the paginated response with {@link PagedIterable}. + */ + PagedIterable list(); + + /** + * List all resources of workspaces for Grafana under the specified subscription. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the paginated response with {@link PagedIterable}. + */ + PagedIterable list(Context context); + + /** + * List all resources of workspaces for Grafana under the specified resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * List all resources of workspaces for Grafana under the specified resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Get the properties of a specific workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @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 properties of a specific workspace for Grafana resource. + */ + ManagedGrafana getByResourceGroup(String resourceGroupName, String workspaceName); + + /** + * Get the properties of a specific workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @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 properties of a specific workspace for Grafana resource along with {@link Response}. + */ + Response getByResourceGroupWithResponse( + String resourceGroupName, String workspaceName, Context context); + + /** + * Delete a workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @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 workspaceName); + + /** + * Delete a workspace for Grafana resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param workspaceName The workspace name of Azure Managed Grafana. + * @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 workspaceName, Context context); + + /** + * Get the properties of a specific workspace for Grafana 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 the properties of a specific workspace for Grafana resource along with {@link Response}. + */ + ManagedGrafana getById(String id); + + /** + * Get the properties of a specific workspace for Grafana 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 the properties of a specific workspace for Grafana resource along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a workspace for Grafana 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 workspace for Grafana 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 ManagedGrafana resource. + * + * @param name resource name. + * @return the first stage of the new ManagedGrafana definition. + */ + ManagedGrafana.DefinitionStages.Blank define(String name); +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/IdentityType.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/IdentityType.java new file mode 100644 index 0000000000000..55136b1d01cc9 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/IdentityType.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.dashboard.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for IdentityType. */ +public final class IdentityType extends ExpandableStringEnum { + /** Static value None for IdentityType. */ + public static final IdentityType NONE = fromString("None"); + + /** Static value SystemAssigned for IdentityType. */ + public static final IdentityType SYSTEM_ASSIGNED = fromString("SystemAssigned"); + + /** + * Creates or finds a IdentityType from its string representation. + * + * @param name a name to look for. + * @return the corresponding IdentityType. + */ + @JsonCreator + public static IdentityType fromString(String name) { + return fromString(name, IdentityType.class); + } + + /** @return known IdentityType values. */ + public static Collection values() { + return values(IdentityType.class); + } +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ManagedGrafana.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ManagedGrafana.java new file mode 100644 index 0000000000000..0e1c18b25ec8d --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ManagedGrafana.java @@ -0,0 +1,265 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.dashboard.models; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.dashboard.fluent.models.ManagedGrafanaInner; +import java.util.Map; + +/** An immutable client-side representation of ManagedGrafana. */ +public interface ManagedGrafana { + /** + * 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 sku property: The Sku of the grafana resource. + * + * @return the sku value. + */ + ResourceSku sku(); + + /** + * Gets the properties property: Properties specific to the grafana resource. + * + * @return the properties value. + */ + ManagedGrafanaProperties properties(); + + /** + * Gets the identity property: The managed identity of the grafana resource. + * + * @return the identity value. + */ + ManagedIdentity identity(); + + /** + * Gets the systemData property: The system meta data relating to this grafana resource. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the region of the resource. + * + * @return the region of the resource. + */ + Region region(); + + /** + * Gets the name of the resource region. + * + * @return the name of the resource region. + */ + String regionName(); + + /** + * Gets the inner com.azure.resourcemanager.dashboard.fluent.models.ManagedGrafanaInner object. + * + * @return the inner object. + */ + ManagedGrafanaInner innerModel(); + + /** The entirety of the ManagedGrafana definition. */ + interface Definition + extends DefinitionStages.Blank, + DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, + DefinitionStages.WithCreate { + } + /** The ManagedGrafana definition stages. */ + interface DefinitionStages { + /** The first stage of the ManagedGrafana definition. */ + interface Blank extends WithLocation { + } + /** The stage of the ManagedGrafana 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 ManagedGrafana 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 ManagedGrafana 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.WithSku, + DefinitionStages.WithProperties, + DefinitionStages.WithIdentity { + /** + * Executes the create request. + * + * @return the created resource. + */ + ManagedGrafana create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + ManagedGrafana create(Context context); + } + /** The stage of the ManagedGrafana 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 ManagedGrafana definition allowing to specify sku. */ + interface WithSku { + /** + * Specifies the sku property: The Sku of the grafana resource.. + * + * @param sku The Sku of the grafana resource. + * @return the next definition stage. + */ + WithCreate withSku(ResourceSku sku); + } + /** The stage of the ManagedGrafana definition allowing to specify properties. */ + interface WithProperties { + /** + * Specifies the properties property: Properties specific to the grafana resource.. + * + * @param properties Properties specific to the grafana resource. + * @return the next definition stage. + */ + WithCreate withProperties(ManagedGrafanaProperties properties); + } + /** The stage of the ManagedGrafana definition allowing to specify identity. */ + interface WithIdentity { + /** + * Specifies the identity property: The managed identity of the grafana resource.. + * + * @param identity The managed identity of the grafana resource. + * @return the next definition stage. + */ + WithCreate withIdentity(ManagedIdentity identity); + } + } + /** + * Begins update for the ManagedGrafana resource. + * + * @return the stage of resource update. + */ + ManagedGrafana.Update update(); + + /** The template for ManagedGrafana update. */ + interface Update extends UpdateStages.WithTags, UpdateStages.WithIdentity { + /** + * Executes the update request. + * + * @return the updated resource. + */ + ManagedGrafana apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + ManagedGrafana apply(Context context); + } + /** The ManagedGrafana update stages. */ + interface UpdateStages { + /** The stage of the ManagedGrafana update allowing to specify tags. */ + interface WithTags { + /** + * Specifies the tags property: The new tags of the grafana resource.. + * + * @param tags The new tags of the grafana resource. + * @return the next definition stage. + */ + Update withTags(Map tags); + } + /** The stage of the ManagedGrafana update allowing to specify identity. */ + interface WithIdentity { + /** + * Specifies the identity property: The managed identity of the grafana resource.. + * + * @param identity The managed identity of the grafana resource. + * @return the next definition stage. + */ + Update withIdentity(ManagedIdentity identity); + } + } + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + ManagedGrafana refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + ManagedGrafana refresh(Context context); +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ManagedGrafanaListResponse.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ManagedGrafanaListResponse.java new file mode 100644 index 0000000000000..34d35ec39103d --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ManagedGrafanaListResponse.java @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.dashboard.models; + +import com.azure.core.annotation.Fluent; +import com.azure.resourcemanager.dashboard.fluent.models.ManagedGrafanaInner; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** The ManagedGrafanaListResponse model. */ +@Fluent +public final class ManagedGrafanaListResponse { + /* + * The value property. + */ + @JsonProperty(value = "value") + private List value; + + /* + * The nextLink property. + */ + @JsonProperty(value = "nextLink") + private String nextLink; + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: The value property. + * + * @param value the value value to set. + * @return the ManagedGrafanaListResponse object itself. + */ + public ManagedGrafanaListResponse withValue(List value) { + this.value = value; + return this; + } + + /** + * Get the nextLink property: The nextLink property. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Set the nextLink property: The nextLink property. + * + * @param nextLink the nextLink value to set. + * @return the ManagedGrafanaListResponse object itself. + */ + public ManagedGrafanaListResponse 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/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ManagedGrafanaProperties.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ManagedGrafanaProperties.java new file mode 100644 index 0000000000000..c81120ff32c6b --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ManagedGrafanaProperties.java @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.dashboard.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Properties specific to the grafana resource. */ +@Fluent +public final class ManagedGrafanaProperties { + /* + * Provisioning state of the resource. + */ + @JsonProperty(value = "provisioningState") + private ProvisioningState provisioningState; + + /* + * The Grafana software version. + */ + @JsonProperty(value = "grafanaVersion", access = JsonProperty.Access.WRITE_ONLY) + private String grafanaVersion; + + /* + * The endpoint of the Grafana instance. + */ + @JsonProperty(value = "endpoint", access = JsonProperty.Access.WRITE_ONLY) + private String endpoint; + + /* + * The zoneRedundancy property. + */ + @JsonProperty(value = "zoneRedundancy") + private ZoneRedundancy zoneRedundancy; + + /* + * The autoGeneratedDomainNameLabelScope property. + */ + @JsonProperty(value = "autoGeneratedDomainNameLabelScope") + private AutoGeneratedDomainNameLabelScope autoGeneratedDomainNameLabelScope; + + /** + * Get the provisioningState property: Provisioning state of the resource. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Set the provisioningState property: Provisioning state of the resource. + * + * @param provisioningState the provisioningState value to set. + * @return the ManagedGrafanaProperties object itself. + */ + public ManagedGrafanaProperties withProvisioningState(ProvisioningState provisioningState) { + this.provisioningState = provisioningState; + return this; + } + + /** + * Get the grafanaVersion property: The Grafana software version. + * + * @return the grafanaVersion value. + */ + public String grafanaVersion() { + return this.grafanaVersion; + } + + /** + * Get the endpoint property: The endpoint of the Grafana instance. + * + * @return the endpoint value. + */ + public String endpoint() { + return this.endpoint; + } + + /** + * Get the zoneRedundancy property: The zoneRedundancy property. + * + * @return the zoneRedundancy value. + */ + public ZoneRedundancy zoneRedundancy() { + return this.zoneRedundancy; + } + + /** + * Set the zoneRedundancy property: The zoneRedundancy property. + * + * @param zoneRedundancy the zoneRedundancy value to set. + * @return the ManagedGrafanaProperties object itself. + */ + public ManagedGrafanaProperties withZoneRedundancy(ZoneRedundancy zoneRedundancy) { + this.zoneRedundancy = zoneRedundancy; + return this; + } + + /** + * Get the autoGeneratedDomainNameLabelScope property: The autoGeneratedDomainNameLabelScope property. + * + * @return the autoGeneratedDomainNameLabelScope value. + */ + public AutoGeneratedDomainNameLabelScope autoGeneratedDomainNameLabelScope() { + return this.autoGeneratedDomainNameLabelScope; + } + + /** + * Set the autoGeneratedDomainNameLabelScope property: The autoGeneratedDomainNameLabelScope property. + * + * @param autoGeneratedDomainNameLabelScope the autoGeneratedDomainNameLabelScope value to set. + * @return the ManagedGrafanaProperties object itself. + */ + public ManagedGrafanaProperties withAutoGeneratedDomainNameLabelScope( + AutoGeneratedDomainNameLabelScope autoGeneratedDomainNameLabelScope) { + this.autoGeneratedDomainNameLabelScope = autoGeneratedDomainNameLabelScope; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ManagedGrafanaUpdateParameters.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ManagedGrafanaUpdateParameters.java new file mode 100644 index 0000000000000..1d0be5880840f --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ManagedGrafanaUpdateParameters.java @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.dashboard.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + +/** The parameters for a PATCH request to a grafana resource. */ +@Fluent +public final class ManagedGrafanaUpdateParameters { + /* + * The managed identity of the grafana resource. + */ + @JsonProperty(value = "identity") + private ManagedIdentity identity; + + /* + * The new tags of the grafana resource. + */ + @JsonProperty(value = "tags") + @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) + private Map tags; + + /** + * Get the identity property: The managed identity of the grafana resource. + * + * @return the identity value. + */ + public ManagedIdentity identity() { + return this.identity; + } + + /** + * Set the identity property: The managed identity of the grafana resource. + * + * @param identity the identity value to set. + * @return the ManagedGrafanaUpdateParameters object itself. + */ + public ManagedGrafanaUpdateParameters withIdentity(ManagedIdentity identity) { + this.identity = identity; + return this; + } + + /** + * Get the tags property: The new tags of the grafana resource. + * + * @return the tags value. + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags property: The new tags of the grafana resource. + * + * @param tags the tags value to set. + * @return the ManagedGrafanaUpdateParameters object itself. + */ + public ManagedGrafanaUpdateParameters withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (identity() != null) { + identity().validate(); + } + } +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ManagedIdentity.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ManagedIdentity.java new file mode 100644 index 0000000000000..fbf64af626241 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ManagedIdentity.java @@ -0,0 +1,119 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.dashboard.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + +/** The managed identity of a resource. */ +@Fluent +public class ManagedIdentity { + /* + * The type 'SystemAssigned, UserAssigned' includes both an implicitly + * created identity and a set of user assigned identities. The type 'None' + * will remove any identities from the resource. + */ + @JsonProperty(value = "type") + private IdentityType type; + + /* + * The principal id of the system assigned identity. + */ + @JsonProperty(value = "principalId", access = JsonProperty.Access.WRITE_ONLY) + private String principalId; + + /* + * The tenant id of the system assigned identity. + */ + @JsonProperty(value = "tenantId", access = JsonProperty.Access.WRITE_ONLY) + private String tenantId; + + /* + * Dictionary of user assigned identities. + */ + @JsonProperty(value = "userAssignedIdentities") + @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) + private Map userAssignedIdentities; + + /** + * Get the type property: The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a + * set of user assigned identities. The type 'None' will remove any identities from the resource. + * + * @return the type value. + */ + public IdentityType type() { + return this.type; + } + + /** + * Set the type property: The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a + * set of user assigned identities. The type 'None' will remove any identities from the resource. + * + * @param type the type value to set. + * @return the ManagedIdentity object itself. + */ + public ManagedIdentity withType(IdentityType type) { + this.type = type; + return this; + } + + /** + * Get the principalId property: The principal id of the system assigned identity. + * + * @return the principalId value. + */ + public String principalId() { + return this.principalId; + } + + /** + * Get the tenantId property: The tenant id of the system assigned identity. + * + * @return the tenantId value. + */ + public String tenantId() { + return this.tenantId; + } + + /** + * Get the userAssignedIdentities property: Dictionary of user assigned identities. + * + * @return the userAssignedIdentities value. + */ + public Map userAssignedIdentities() { + return this.userAssignedIdentities; + } + + /** + * Set the userAssignedIdentities property: Dictionary of user assigned identities. + * + * @param userAssignedIdentities the userAssignedIdentities value to set. + * @return the ManagedIdentity object itself. + */ + public ManagedIdentity withUserAssignedIdentities(Map userAssignedIdentities) { + this.userAssignedIdentities = userAssignedIdentities; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (userAssignedIdentities() != null) { + userAssignedIdentities() + .values() + .forEach( + e -> { + if (e != null) { + e.validate(); + } + }); + } + } +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/OperationDisplay.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/OperationDisplay.java new file mode 100644 index 0000000000000..b935069995e4e --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/OperationDisplay.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.dashboard.models; + +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Localized display information for this particular operation. */ +@Immutable +public final class OperationDisplay { + /* + * The localized friendly form of the resource provider name, i.e., + * Microsoft.Dashboard. + */ + @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., 'grafana'. + */ + @JsonProperty(value = "resource", access = JsonProperty.Access.WRITE_ONLY) + private String resource; + + /* + * Operation type, e.g., read, write, delete, etc. + */ + @JsonProperty(value = "operation", access = JsonProperty.Access.WRITE_ONLY) + private String operation; + + /* + * Description of the operation, e.g., 'Read grafana'. + */ + @JsonProperty(value = "description", access = JsonProperty.Access.WRITE_ONLY) + private String description; + + /** + * Get the provider property: The localized friendly form of the resource provider name, i.e., Microsoft.Dashboard. + * + * @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., + * 'grafana'. + * + * @return the resource value. + */ + public String resource() { + return this.resource; + } + + /** + * Get the operation property: Operation type, e.g., read, write, delete, etc. + * + * @return the operation value. + */ + public String operation() { + return this.operation; + } + + /** + * Get the description property: Description of the operation, e.g., 'Read grafana'. + * + * @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/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/OperationListResult.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/OperationListResult.java new file mode 100644 index 0000000000000..d26174cef834a --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/OperationListResult.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.dashboard.models; + +import com.azure.core.annotation.Immutable; +import com.azure.resourcemanager.dashboard.fluent.models.OperationResultInner; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** + * A list of REST API operations supported by Microsoft.Dashboard provider. It contains an URL link to get the next set + * of results. + */ +@Immutable +public final class OperationListResult { + /* + * List of operations supported by the Microsoft.Dashboard 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 Microsoft.Dashboard 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/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/OperationResult.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/OperationResult.java new file mode 100644 index 0000000000000..d4a2a98784215 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/OperationResult.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.dashboard.models; + +import com.azure.resourcemanager.dashboard.fluent.models.OperationResultInner; + +/** An immutable client-side representation of OperationResult. */ +public interface OperationResult { + /** + * Gets the name property: Operation name, i.e., {provider}/{resource}/{operation}. + * + * @return the name value. + */ + String name(); + + /** + * Gets the isDataAction property: Indicates whether the operation applies to data-plane. Set "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. + * + * @return the origin value. + */ + Origin origin(); + + /** + * Gets the actionType property: 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.dashboard.fluent.models.OperationResultInner object. + * + * @return the inner object. + */ + OperationResultInner innerModel(); +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/Operations.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/Operations.java new file mode 100644 index 0000000000000..ae1a6cd046cf6 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/Operations.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.dashboard.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; + +/** Resource collection API of Operations. */ +public interface Operations { + /** + * List all available API operations provided by Microsoft.Dashboard. + * + * @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 Microsoft.Dashboard provider as paginated response with {@link + * PagedIterable}. + */ + PagedIterable list(); + + /** + * List all available API operations provided by Microsoft.Dashboard. + * + * @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 Microsoft.Dashboard provider as paginated response with {@link + * PagedIterable}. + */ + PagedIterable list(Context context); +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/Origin.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/Origin.java new file mode 100644 index 0000000000000..c8771de66be22 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/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.dashboard.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/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ProvisioningState.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ProvisioningState.java new file mode 100644 index 0000000000000..5d1df91f64aa7 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ProvisioningState.java @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.dashboard.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for ProvisioningState. */ +public final class ProvisioningState extends ExpandableStringEnum { + /** Static value Accepted for ProvisioningState. */ + public static final ProvisioningState ACCEPTED = fromString("Accepted"); + + /** Static value Creating for ProvisioningState. */ + public static final ProvisioningState CREATING = fromString("Creating"); + + /** Static value Updating for ProvisioningState. */ + public static final ProvisioningState UPDATING = fromString("Updating"); + + /** Static value Deleting for ProvisioningState. */ + public static final ProvisioningState DELETING = fromString("Deleting"); + + /** Static value Succeeded for ProvisioningState. */ + public static final ProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** Static value Failed for ProvisioningState. */ + public static final ProvisioningState FAILED = fromString("Failed"); + + /** Static value Canceled for ProvisioningState. */ + public static final ProvisioningState CANCELED = fromString("Canceled"); + + /** Static value Deleted for ProvisioningState. */ + public static final ProvisioningState DELETED = fromString("Deleted"); + + /** Static value NotSpecified for ProvisioningState. */ + public static final ProvisioningState NOT_SPECIFIED = fromString("NotSpecified"); + + /** + * Creates or finds a ProvisioningState from its string representation. + * + * @param name a name to look for. + * @return the corresponding ProvisioningState. + */ + @JsonCreator + public static ProvisioningState fromString(String name) { + return fromString(name, ProvisioningState.class); + } + + /** @return known ProvisioningState values. */ + public static Collection values() { + return values(ProvisioningState.class); + } +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ResourceSku.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ResourceSku.java new file mode 100644 index 0000000000000..7af2c3ce2a2bc --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ResourceSku.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.dashboard.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The ResourceSku model. */ +@Fluent +public final class ResourceSku { + /* + * The name property. + */ + @JsonProperty(value = "name", required = true) + private String name; + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: The name property. + * + * @param name the name value to set. + * @return the ResourceSku object itself. + */ + public ResourceSku withName(String name) { + this.name = name; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() == null) { + throw LOGGER + .logExceptionAsError( + new IllegalArgumentException("Missing required property name in model ResourceSku")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ResourceSku.class); +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/UserAssignedIdentity.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/UserAssignedIdentity.java new file mode 100644 index 0000000000000..ba6a703844d8c --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/UserAssignedIdentity.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.dashboard.models; + +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The UserAssignedIdentity model. */ +@Immutable +public class UserAssignedIdentity { + /* + * The principal id of user assigned identity. + */ + @JsonProperty(value = "principalId", access = JsonProperty.Access.WRITE_ONLY) + private String principalId; + + /* + * The client id of user assigned identity. + */ + @JsonProperty(value = "clientId", access = JsonProperty.Access.WRITE_ONLY) + private String clientId; + + /** + * Get the principalId property: The principal id of user assigned identity. + * + * @return the principalId value. + */ + public String principalId() { + return this.principalId; + } + + /** + * Get the clientId property: The client id of user assigned identity. + * + * @return the clientId value. + */ + public String clientId() { + return this.clientId; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ZoneRedundancy.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ZoneRedundancy.java new file mode 100644 index 0000000000000..af6b859b6e918 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/ZoneRedundancy.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.dashboard.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for ZoneRedundancy. */ +public final class ZoneRedundancy extends ExpandableStringEnum { + /** Static value Disabled for ZoneRedundancy. */ + public static final ZoneRedundancy DISABLED = fromString("Disabled"); + + /** Static value Enabled for ZoneRedundancy. */ + public static final ZoneRedundancy ENABLED = fromString("Enabled"); + + /** + * Creates or finds a ZoneRedundancy from its string representation. + * + * @param name a name to look for. + * @return the corresponding ZoneRedundancy. + */ + @JsonCreator + public static ZoneRedundancy fromString(String name) { + return fromString(name, ZoneRedundancy.class); + } + + /** @return known ZoneRedundancy values. */ + public static Collection values() { + return values(ZoneRedundancy.class); + } +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/package-info.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/package-info.java new file mode 100644 index 0000000000000..b799cb25bbbe4 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/models/package-info.java @@ -0,0 +1,6 @@ +// 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 DashboardManagementClient. The Microsoft.Dashboard Rest API spec. */ +package com.azure.resourcemanager.dashboard.models; diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/package-info.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/package-info.java new file mode 100644 index 0000000000000..d6fdce2047c6f --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/com/azure/resourcemanager/dashboard/package-info.java @@ -0,0 +1,6 @@ +// 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 DashboardManagementClient. The Microsoft.Dashboard Rest API spec. */ +package com.azure.resourcemanager.dashboard; diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/module-info.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/main/java/module-info.java new file mode 100644 index 0000000000000..547a07179894f --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/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.dashboard { + requires transitive com.azure.core.management; + + exports com.azure.resourcemanager.dashboard; + exports com.azure.resourcemanager.dashboard.fluent; + exports com.azure.resourcemanager.dashboard.fluent.models; + exports com.azure.resourcemanager.dashboard.models; + + opens com.azure.resourcemanager.dashboard.fluent.models to + com.azure.core, + com.fasterxml.jackson.databind; + opens com.azure.resourcemanager.dashboard.models to + com.azure.core, + com.fasterxml.jackson.databind; +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaCreateSamples.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaCreateSamples.java new file mode 100644 index 0000000000000..43566b1ff42f4 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaCreateSamples.java @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.dashboard.generated; + +import com.azure.resourcemanager.dashboard.models.IdentityType; +import com.azure.resourcemanager.dashboard.models.ManagedGrafanaProperties; +import com.azure.resourcemanager.dashboard.models.ManagedIdentity; +import com.azure.resourcemanager.dashboard.models.ProvisioningState; +import com.azure.resourcemanager.dashboard.models.ResourceSku; +import com.azure.resourcemanager.dashboard.models.ZoneRedundancy; +import java.util.HashMap; +import java.util.Map; + +/** Samples for Grafana Create. */ +public final class GrafanaCreateSamples { + /* + * x-ms-original-file: specification/dashboard/resource-manager/Microsoft.Dashboard/preview/2021-09-01-preview/examples/Grafana_Create.json + */ + /** + * Sample code: Grafana_Create. + * + * @param manager Entry point to DashboardManager. + */ + public static void grafanaCreate(com.azure.resourcemanager.dashboard.DashboardManager manager) { + manager + .grafanas() + .define("myWorkspace") + .withRegion("West US") + .withExistingResourceGroup("myResourceGroup") + .withTags(mapOf("Environment", "Dev")) + .withSku(new ResourceSku().withName("Standard")) + .withProperties( + new ManagedGrafanaProperties() + .withProvisioningState(ProvisioningState.ACCEPTED) + .withZoneRedundancy(ZoneRedundancy.ENABLED)) + .withIdentity(new ManagedIdentity().withType(IdentityType.SYSTEM_ASSIGNED)) + .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/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaDeleteSamples.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaDeleteSamples.java new file mode 100644 index 0000000000000..fd629688bc26d --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaDeleteSamples.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.dashboard.generated; + +import com.azure.core.util.Context; + +/** Samples for Grafana Delete. */ +public final class GrafanaDeleteSamples { + /* + * x-ms-original-file: specification/dashboard/resource-manager/Microsoft.Dashboard/preview/2021-09-01-preview/examples/Grafana_Delete.json + */ + /** + * Sample code: Grafana_Delete. + * + * @param manager Entry point to DashboardManager. + */ + public static void grafanaDelete(com.azure.resourcemanager.dashboard.DashboardManager manager) { + manager.grafanas().delete("myResourceGroup", "myWorkspace", Context.NONE); + } +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaGetByResourceGroupSamples.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaGetByResourceGroupSamples.java new file mode 100644 index 0000000000000..b8359034e531a --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaGetByResourceGroupSamples.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.dashboard.generated; + +import com.azure.core.util.Context; + +/** Samples for Grafana GetByResourceGroup. */ +public final class GrafanaGetByResourceGroupSamples { + /* + * x-ms-original-file: specification/dashboard/resource-manager/Microsoft.Dashboard/preview/2021-09-01-preview/examples/Grafana_Get.json + */ + /** + * Sample code: Grafana_Get. + * + * @param manager Entry point to DashboardManager. + */ + public static void grafanaGet(com.azure.resourcemanager.dashboard.DashboardManager manager) { + manager.grafanas().getByResourceGroupWithResponse("myResourceGroup", "myWorkspace", Context.NONE); + } +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaListByResourceGroupSamples.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaListByResourceGroupSamples.java new file mode 100644 index 0000000000000..6d11b3976188e --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaListByResourceGroupSamples.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.dashboard.generated; + +import com.azure.core.util.Context; + +/** Samples for Grafana ListByResourceGroup. */ +public final class GrafanaListByResourceGroupSamples { + /* + * x-ms-original-file: specification/dashboard/resource-manager/Microsoft.Dashboard/preview/2021-09-01-preview/examples/Grafana_ListByResourceGroup.json + */ + /** + * Sample code: Grafana_ListByResourceGroup. + * + * @param manager Entry point to DashboardManager. + */ + public static void grafanaListByResourceGroup(com.azure.resourcemanager.dashboard.DashboardManager manager) { + manager.grafanas().listByResourceGroup("myResourceGroup", Context.NONE); + } +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaListSamples.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaListSamples.java new file mode 100644 index 0000000000000..b19a4d5a7109b --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaListSamples.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.dashboard.generated; + +import com.azure.core.util.Context; + +/** Samples for Grafana List. */ +public final class GrafanaListSamples { + /* + * x-ms-original-file: specification/dashboard/resource-manager/Microsoft.Dashboard/preview/2021-09-01-preview/examples/Grafana_List.json + */ + /** + * Sample code: Grafana_List. + * + * @param manager Entry point to DashboardManager. + */ + public static void grafanaList(com.azure.resourcemanager.dashboard.DashboardManager manager) { + manager.grafanas().list(Context.NONE); + } +} diff --git a/sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaUpdateSamples.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaUpdateSamples.java new file mode 100644 index 0000000000000..0472e1a8597f4 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/GrafanaUpdateSamples.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.dashboard.generated; + +import com.azure.core.util.Context; +import com.azure.resourcemanager.dashboard.models.ManagedGrafana; +import java.util.HashMap; +import java.util.Map; + +/** Samples for Grafana Update. */ +public final class GrafanaUpdateSamples { + /* + * x-ms-original-file: specification/dashboard/resource-manager/Microsoft.Dashboard/preview/2021-09-01-preview/examples/Grafana_Update.json + */ + /** + * Sample code: Grafana_Update. + * + * @param manager Entry point to DashboardManager. + */ + public static void grafanaUpdate(com.azure.resourcemanager.dashboard.DashboardManager manager) { + ManagedGrafana resource = + manager + .grafanas() + .getByResourceGroupWithResponse("myResourceGroup", "myWorkspace", Context.NONE) + .getValue(); + resource.update().withTags(mapOf("Environment", "Dev 2")).apply(); + } + + @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/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/OperationsListSamples.java b/sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/generated/OperationsListSamples.java new file mode 100644 index 0000000000000..c1a4a8d8f4c64 --- /dev/null +++ b/sdk/dashboard/azure-resourcemanager-dashboard/src/samples/java/com/azure/resourcemanager/dashboard/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.dashboard.generated; + +import com.azure.core.util.Context; + +/** Samples for Operations List. */ +public final class OperationsListSamples { + /* + * x-ms-original-file: specification/dashboard/resource-manager/Microsoft.Dashboard/preview/2021-09-01-preview/examples/Operations_List.json + */ + /** + * Sample code: Operations_List. + * + * @param manager Entry point to DashboardManager. + */ + public static void operationsList(com.azure.resourcemanager.dashboard.DashboardManager manager) { + manager.operations().list(Context.NONE); + } +} diff --git a/sdk/dashboard/ci.yml b/sdk/dashboard/ci.yml new file mode 100644 index 0000000000000..afb258461edd1 --- /dev/null +++ b/sdk/dashboard/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/dashboard/ci.yml + - sdk/dashboard/azure-resourcemanager-dashboard/ + exclude: + - sdk/dashboard/pom.xml + - sdk/dashboard/azure-resourcemanager-dashboard/pom.xml + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/dashboard/ci.yml + - sdk/dashboard/azure-resourcemanager-dashboard/ + exclude: + - sdk/dashboard/pom.xml + - sdk/dashboard/azure-resourcemanager-dashboard/pom.xml + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: dashboard + Artifacts: + - name: azure-resourcemanager-dashboard + groupId: com.azure.resourcemanager + safeName: azureresourcemanagerdashboard diff --git a/sdk/dashboard/pom.xml b/sdk/dashboard/pom.xml new file mode 100644 index 0000000000000..96f281f5c1ab3 --- /dev/null +++ b/sdk/dashboard/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + com.azure + azure-dashboard-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-dashboard + + + +