From f9928c8bb1b8fa67e9ce8a407e6dbdf0f28c4d48 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 26 Feb 2021 08:30:51 +0000 Subject: [PATCH] CodeGen from PR 13166 in Azure/azure-rest-api-specs Merge b353336f78b47a9a9d83765d68a6b9b87ea76f95 into 89f00c23e9b247304c490504f182aebd0dff4f4e --- .../azure-resourcemanager-kusto/CHANGELOG.md | 3 +- .../azure-resourcemanager-kusto/README.md | 18 +- sdk/kusto/azure-resourcemanager-kusto/pom.xml | 5 + .../resourcemanager/kusto/KustoManager.java | 28 ++- .../AttachedDatabaseConfigurationsImpl.java | 4 +- .../kusto/implementation/ClusterImpl.java | 75 ++++++++ .../ClusterPrincipalAssignmentsImpl.java | 4 +- .../kusto/implementation/ClustersImpl.java | 24 +-- .../implementation/DataConnectionsImpl.java | 4 +- .../DatabasePrincipalAssignmentsImpl.java | 4 +- .../kusto/implementation/DatabasesImpl.java | 8 +- .../KustoManagementClientImpl.java | 4 +- .../kusto/implementation/OperationsImpl.java | 4 +- .../kusto/implementation/Utils.java | 129 ++++++++++++++ .../resourcemanager/kusto/models/Cluster.java | 161 ++++++++++++++++++ 15 files changed, 438 insertions(+), 37 deletions(-) diff --git a/sdk/kusto/azure-resourcemanager-kusto/CHANGELOG.md b/sdk/kusto/azure-resourcemanager-kusto/CHANGELOG.md index ff301aaadbdeb..fc62d8dc64112 100644 --- a/sdk/kusto/azure-resourcemanager-kusto/CHANGELOG.md +++ b/sdk/kusto/azure-resourcemanager-kusto/CHANGELOG.md @@ -1,7 +1,8 @@ # Release History -## 1.0.0-beta.2 (Unreleased) +## 1.0.0-beta.1 (2021-02-26) +- Azure Resource Manager Kusto client library for Java. This package contains Microsoft Azure SDK for Kusto Management SDK. The Azure Kusto management API provides a RESTful set of web services that interact with Azure Kusto services to manage your clusters and databases. The API enables you to create, update, and delete clusters and databases. Package tag package-2020-09-18. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). ## 1.0.0-beta.1 (2020-12-18) diff --git a/sdk/kusto/azure-resourcemanager-kusto/README.md b/sdk/kusto/azure-resourcemanager-kusto/README.md index 1c4f49078b3e2..699a29f670838 100644 --- a/sdk/kusto/azure-resourcemanager-kusto/README.md +++ b/sdk/kusto/azure-resourcemanager-kusto/README.md @@ -4,6 +4,20 @@ Azure Resource Manager Kusto client library for Java. This package contains Microsoft Azure SDK for Kusto Management SDK. The Azure Kusto management API provides a RESTful set of web services that interact with Azure Kusto services to manage your clusters and databases. The API enables you to create, update, and delete clusters and databases. Package tag package-2020-09-18. 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 @@ -18,7 +32,7 @@ This package contains Microsoft Azure SDK for Kusto Management SDK. The Azure Ku com.azure.resourcemanager azure-resourcemanager-kusto - 1.0.0-beta.1 + 1.0.0-beta.2 ``` [//]: # ({x-version-update-end}) @@ -75,6 +89,8 @@ For details on contributing to this repository, see the [contributing guide](htt 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/master/sdk/identity/azure-identity diff --git a/sdk/kusto/azure-resourcemanager-kusto/pom.xml b/sdk/kusto/azure-resourcemanager-kusto/pom.xml index f6cdef2ad56bc..ae37871518f52 100644 --- a/sdk/kusto/azure-resourcemanager-kusto/pom.xml +++ b/sdk/kusto/azure-resourcemanager-kusto/pom.xml @@ -41,6 +41,11 @@ + + com.azure + azure-core + 1.13.0 + com.azure azure-core-management diff --git a/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/KustoManager.java b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/KustoManager.java index e35bcd166bdd6..3005908bd061a 100644 --- a/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/KustoManager.java +++ b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/KustoManager.java @@ -180,17 +180,31 @@ public KustoManager authenticate(TokenCredential credential, AzureProfile profil 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.kusto") + .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 (retryPolicy == null) { retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); } List policies = new ArrayList<>(); - policies - .add( - new UserAgentPolicy( - null, - "com.azure.resourcemanager.kusto", - "1.0.0-beta.1", - Configuration.getGlobalConfiguration())); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); policies.add(new RequestIdPolicy()); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(retryPolicy); diff --git a/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/AttachedDatabaseConfigurationsImpl.java b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/AttachedDatabaseConfigurationsImpl.java index 41909d2a27aa3..69a53ec333e20 100644 --- a/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/AttachedDatabaseConfigurationsImpl.java +++ b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/AttachedDatabaseConfigurationsImpl.java @@ -32,14 +32,14 @@ public AttachedDatabaseConfigurationsImpl( public PagedIterable listByCluster(String resourceGroupName, String clusterName) { PagedIterable inner = this.serviceClient().listByCluster(resourceGroupName, clusterName); - return inner.mapPage(inner1 -> new AttachedDatabaseConfigurationImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new AttachedDatabaseConfigurationImpl(inner1, this.manager())); } public PagedIterable listByCluster( String resourceGroupName, String clusterName, Context context) { PagedIterable inner = this.serviceClient().listByCluster(resourceGroupName, clusterName, context); - return inner.mapPage(inner1 -> new AttachedDatabaseConfigurationImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new AttachedDatabaseConfigurationImpl(inner1, this.manager())); } public AttachedDatabaseConfiguration get( diff --git a/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/ClusterImpl.java b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/ClusterImpl.java index ba154061dd4b7..9e45589954721 100644 --- a/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/ClusterImpl.java +++ b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/ClusterImpl.java @@ -4,16 +4,21 @@ package com.azure.resourcemanager.kusto.implementation; +import com.azure.core.http.rest.PagedIterable; import com.azure.core.management.Region; import com.azure.core.util.Context; import com.azure.resourcemanager.kusto.KustoManager; import com.azure.resourcemanager.kusto.fluent.models.ClusterInner; +import com.azure.resourcemanager.kusto.fluent.models.FollowerDatabaseDefinitionInner; import com.azure.resourcemanager.kusto.models.AzureSku; import com.azure.resourcemanager.kusto.models.Cluster; import com.azure.resourcemanager.kusto.models.ClusterUpdate; +import com.azure.resourcemanager.kusto.models.DiagnoseVirtualNetworkResult; import com.azure.resourcemanager.kusto.models.EngineType; +import com.azure.resourcemanager.kusto.models.FollowerDatabaseDefinition; import com.azure.resourcemanager.kusto.models.Identity; import com.azure.resourcemanager.kusto.models.KeyVaultProperties; +import com.azure.resourcemanager.kusto.models.LanguageExtension; import com.azure.resourcemanager.kusto.models.LanguageExtensionsList; import com.azure.resourcemanager.kusto.models.OptimizedAutoscale; import com.azure.resourcemanager.kusto.models.ProvisioningState; @@ -237,6 +242,76 @@ public Cluster refresh(Context context) { return this; } + public void stop() { + serviceManager.clusters().stop(resourceGroupName, clusterName); + } + + public void stop(Context context) { + serviceManager.clusters().stop(resourceGroupName, clusterName, context); + } + + public void start() { + serviceManager.clusters().start(resourceGroupName, clusterName); + } + + public void start(Context context) { + serviceManager.clusters().start(resourceGroupName, clusterName, context); + } + + public PagedIterable listFollowerDatabases() { + return serviceManager.clusters().listFollowerDatabases(resourceGroupName, clusterName); + } + + public PagedIterable listFollowerDatabases(Context context) { + return serviceManager.clusters().listFollowerDatabases(resourceGroupName, clusterName, context); + } + + public void detachFollowerDatabases(FollowerDatabaseDefinitionInner followerDatabaseToRemove) { + serviceManager.clusters().detachFollowerDatabases(resourceGroupName, clusterName, followerDatabaseToRemove); + } + + public void detachFollowerDatabases(FollowerDatabaseDefinitionInner followerDatabaseToRemove, Context context) { + serviceManager + .clusters() + .detachFollowerDatabases(resourceGroupName, clusterName, followerDatabaseToRemove, context); + } + + public DiagnoseVirtualNetworkResult diagnoseVirtualNetwork() { + return serviceManager.clusters().diagnoseVirtualNetwork(resourceGroupName, clusterName); + } + + public DiagnoseVirtualNetworkResult diagnoseVirtualNetwork(Context context) { + return serviceManager.clusters().diagnoseVirtualNetwork(resourceGroupName, clusterName, context); + } + + public PagedIterable listLanguageExtensions() { + return serviceManager.clusters().listLanguageExtensions(resourceGroupName, clusterName); + } + + public PagedIterable listLanguageExtensions(Context context) { + return serviceManager.clusters().listLanguageExtensions(resourceGroupName, clusterName, context); + } + + public void addLanguageExtensions(LanguageExtensionsList languageExtensionsToAdd) { + serviceManager.clusters().addLanguageExtensions(resourceGroupName, clusterName, languageExtensionsToAdd); + } + + public void addLanguageExtensions(LanguageExtensionsList languageExtensionsToAdd, Context context) { + serviceManager + .clusters() + .addLanguageExtensions(resourceGroupName, clusterName, languageExtensionsToAdd, context); + } + + public void removeLanguageExtensions(LanguageExtensionsList languageExtensionsToRemove) { + serviceManager.clusters().removeLanguageExtensions(resourceGroupName, clusterName, languageExtensionsToRemove); + } + + public void removeLanguageExtensions(LanguageExtensionsList languageExtensionsToRemove, Context context) { + serviceManager + .clusters() + .removeLanguageExtensions(resourceGroupName, clusterName, languageExtensionsToRemove, context); + } + public ClusterImpl withRegion(Region location) { this.innerModel().withLocation(location.toString()); return this; diff --git a/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/ClusterPrincipalAssignmentsImpl.java b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/ClusterPrincipalAssignmentsImpl.java index 9074c340fdf24..aee1eda168fac 100644 --- a/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/ClusterPrincipalAssignmentsImpl.java +++ b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/ClusterPrincipalAssignmentsImpl.java @@ -101,14 +101,14 @@ public void delete(String resourceGroupName, String clusterName, String principa public PagedIterable list(String resourceGroupName, String clusterName) { PagedIterable inner = this.serviceClient().list(resourceGroupName, clusterName); - return inner.mapPage(inner1 -> new ClusterPrincipalAssignmentImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new ClusterPrincipalAssignmentImpl(inner1, this.manager())); } public PagedIterable list( String resourceGroupName, String clusterName, Context context) { PagedIterable inner = this.serviceClient().list(resourceGroupName, clusterName, context); - return inner.mapPage(inner1 -> new ClusterPrincipalAssignmentImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new ClusterPrincipalAssignmentImpl(inner1, this.manager())); } public ClusterPrincipalAssignment getById(String id) { diff --git a/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/ClustersImpl.java b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/ClustersImpl.java index 150184605c9e4..3b1fa952f5a65 100644 --- a/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/ClustersImpl.java +++ b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/ClustersImpl.java @@ -94,14 +94,14 @@ public PagedIterable listFollowerDatabases( String resourceGroupName, String clusterName) { PagedIterable inner = this.serviceClient().listFollowerDatabases(resourceGroupName, clusterName); - return inner.mapPage(inner1 -> new FollowerDatabaseDefinitionImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new FollowerDatabaseDefinitionImpl(inner1, this.manager())); } public PagedIterable listFollowerDatabases( String resourceGroupName, String clusterName, Context context) { PagedIterable inner = this.serviceClient().listFollowerDatabases(resourceGroupName, clusterName, context); - return inner.mapPage(inner1 -> new FollowerDatabaseDefinitionImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new FollowerDatabaseDefinitionImpl(inner1, this.manager())); } public void detachFollowerDatabases( @@ -140,32 +140,32 @@ public DiagnoseVirtualNetworkResult diagnoseVirtualNetwork( public PagedIterable listByResourceGroup(String resourceGroupName) { PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName); - return inner.mapPage(inner1 -> new ClusterImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new ClusterImpl(inner1, this.manager())); } public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName, context); - return inner.mapPage(inner1 -> new ClusterImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new ClusterImpl(inner1, this.manager())); } public PagedIterable list() { PagedIterable inner = this.serviceClient().list(); - return inner.mapPage(inner1 -> new ClusterImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new ClusterImpl(inner1, this.manager())); } public PagedIterable list(Context context) { PagedIterable inner = this.serviceClient().list(context); - return inner.mapPage(inner1 -> new ClusterImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new ClusterImpl(inner1, this.manager())); } public PagedIterable listSkus() { PagedIterable inner = this.serviceClient().listSkus(); - return inner.mapPage(inner1 -> new SkuDescriptionImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new SkuDescriptionImpl(inner1, this.manager())); } public PagedIterable listSkus(Context context) { PagedIterable inner = this.serviceClient().listSkus(context); - return inner.mapPage(inner1 -> new SkuDescriptionImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new SkuDescriptionImpl(inner1, this.manager())); } public CheckNameResult checkNameAvailability(String location, ClusterCheckNameRequest clusterName) { @@ -195,27 +195,27 @@ public Response checkNameAvailabilityWithResponse( public PagedIterable listSkusByResource(String resourceGroupName, String clusterName) { PagedIterable inner = this.serviceClient().listSkusByResource(resourceGroupName, clusterName); - return inner.mapPage(inner1 -> new AzureResourceSkuImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new AzureResourceSkuImpl(inner1, this.manager())); } public PagedIterable listSkusByResource( String resourceGroupName, String clusterName, Context context) { PagedIterable inner = this.serviceClient().listSkusByResource(resourceGroupName, clusterName, context); - return inner.mapPage(inner1 -> new AzureResourceSkuImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new AzureResourceSkuImpl(inner1, this.manager())); } public PagedIterable listLanguageExtensions(String resourceGroupName, String clusterName) { PagedIterable inner = this.serviceClient().listLanguageExtensions(resourceGroupName, clusterName); - return inner.mapPage(inner1 -> new LanguageExtensionImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new LanguageExtensionImpl(inner1, this.manager())); } public PagedIterable listLanguageExtensions( String resourceGroupName, String clusterName, Context context) { PagedIterable inner = this.serviceClient().listLanguageExtensions(resourceGroupName, clusterName, context); - return inner.mapPage(inner1 -> new LanguageExtensionImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new LanguageExtensionImpl(inner1, this.manager())); } public void addLanguageExtensions( diff --git a/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/DataConnectionsImpl.java b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/DataConnectionsImpl.java index 15d6b180da3b0..2dc381c07ae25 100644 --- a/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/DataConnectionsImpl.java +++ b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/DataConnectionsImpl.java @@ -38,14 +38,14 @@ public PagedIterable listByDatabase( String resourceGroupName, String clusterName, String databaseName) { PagedIterable inner = this.serviceClient().listByDatabase(resourceGroupName, clusterName, databaseName); - return inner.mapPage(inner1 -> new DataConnectionImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new DataConnectionImpl(inner1, this.manager())); } public PagedIterable listByDatabase( String resourceGroupName, String clusterName, String databaseName, Context context) { PagedIterable inner = this.serviceClient().listByDatabase(resourceGroupName, clusterName, databaseName, context); - return inner.mapPage(inner1 -> new DataConnectionImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new DataConnectionImpl(inner1, this.manager())); } public DataConnectionValidationListResult dataConnectionValidation( diff --git a/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/DatabasePrincipalAssignmentsImpl.java b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/DatabasePrincipalAssignmentsImpl.java index 55c5c04c735c4..db92d0e02b321 100644 --- a/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/DatabasePrincipalAssignmentsImpl.java +++ b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/DatabasePrincipalAssignmentsImpl.java @@ -120,14 +120,14 @@ public PagedIterable list( String resourceGroupName, String clusterName, String databaseName) { PagedIterable inner = this.serviceClient().list(resourceGroupName, clusterName, databaseName); - return inner.mapPage(inner1 -> new DatabasePrincipalAssignmentImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new DatabasePrincipalAssignmentImpl(inner1, this.manager())); } public PagedIterable list( String resourceGroupName, String clusterName, String databaseName, Context context) { PagedIterable inner = this.serviceClient().list(resourceGroupName, clusterName, databaseName, context); - return inner.mapPage(inner1 -> new DatabasePrincipalAssignmentImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new DatabasePrincipalAssignmentImpl(inner1, this.manager())); } public DatabasePrincipalAssignment getById(String id) { diff --git a/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/DatabasesImpl.java b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/DatabasesImpl.java index b961c2ace1b64..970fc1042b1f5 100644 --- a/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/DatabasesImpl.java +++ b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/DatabasesImpl.java @@ -66,13 +66,13 @@ public Response checkNameAvailabilityWithResponse( public PagedIterable listByCluster(String resourceGroupName, String clusterName) { PagedIterable inner = this.serviceClient().listByCluster(resourceGroupName, clusterName); - return inner.mapPage(inner1 -> new DatabaseImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new DatabaseImpl(inner1, this.manager())); } public PagedIterable listByCluster(String resourceGroupName, String clusterName, Context context) { PagedIterable inner = this.serviceClient().listByCluster(resourceGroupName, clusterName, context); - return inner.mapPage(inner1 -> new DatabaseImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new DatabaseImpl(inner1, this.manager())); } public Database get(String resourceGroupName, String clusterName, String databaseName) { @@ -154,14 +154,14 @@ public PagedIterable listPrincipals( String resourceGroupName, String clusterName, String databaseName) { PagedIterable inner = this.serviceClient().listPrincipals(resourceGroupName, clusterName, databaseName); - return inner.mapPage(inner1 -> new DatabasePrincipalImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new DatabasePrincipalImpl(inner1, this.manager())); } public PagedIterable listPrincipals( String resourceGroupName, String clusterName, String databaseName, Context context) { PagedIterable inner = this.serviceClient().listPrincipals(resourceGroupName, clusterName, databaseName, context); - return inner.mapPage(inner1 -> new DatabasePrincipalImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new DatabasePrincipalImpl(inner1, this.manager())); } public DatabasePrincipalListResult addPrincipals( diff --git a/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/KustoManagementClientImpl.java b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/KustoManagementClientImpl.java index cf1e8404ad1e6..12fc58e81f753 100644 --- a/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/KustoManagementClientImpl.java +++ b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/KustoManagementClientImpl.java @@ -319,7 +319,7 @@ public Mono getLroFinalResultOrError(AsyncPollResponse, if (managementError.getCode() == null || managementError.getMessage() == null) { managementError = null; } - } catch (IOException ioe) { + } catch (IOException | RuntimeException ioe) { logger.logThrowableAsWarning(ioe); } } @@ -348,7 +348,7 @@ private static final class HttpResponseImpl extends HttpResponse { super(null); this.statusCode = statusCode; this.httpHeaders = httpHeaders; - this.responseBody = responseBody.getBytes(StandardCharsets.UTF_8); + this.responseBody = responseBody == null ? null : responseBody.getBytes(StandardCharsets.UTF_8); } public int getStatusCode() { diff --git a/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/OperationsImpl.java b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/OperationsImpl.java index b51bd4a31330e..4a1f09e71f1a1 100644 --- a/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/OperationsImpl.java +++ b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/OperationsImpl.java @@ -28,12 +28,12 @@ public OperationsImpl(OperationsClient innerClient, KustoManager serviceManager) public PagedIterable list() { PagedIterable inner = this.serviceClient().list(); - return inner.mapPage(inner1 -> new OperationImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); } public PagedIterable list(Context context) { PagedIterable inner = this.serviceClient().list(context); - return inner.mapPage(inner1 -> new OperationImpl(inner1, this.manager())); + return Utils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); } private OperationsClient serviceClient() { diff --git a/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/Utils.java b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/Utils.java index 457814f522a16..5865dd53469f7 100644 --- a/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/Utils.java +++ b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/implementation/Utils.java @@ -4,12 +4,20 @@ package com.azure.resourcemanager.kusto.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.Mono; final class Utils { static String getValueFromIdByName(String id, String name) { @@ -64,4 +72,125 @@ static String getValueFromIdByParameterName(String id, String pathTemplate, Stri } return null; } + + static PagedIterable mapPage(PagedIterable pageIterable, Function mapper) { + return new PagedIterableImpl(pageIterable, mapper); + } + + private static final class PagedIterableImpl extends PagedIterable { + + private final PagedIterable pageIterable; + private final Function mapper; + private final Function, PagedResponse> pageMapper; + + private PagedIterableImpl(PagedIterable pageIterable, Function mapper) { + super(new PagedFlux(Mono::empty)); + this.pageIterable = pageIterable; + this.mapper = mapper; + this.pageMapper = + 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 pageIterable.stream().map(mapper); + } + + @Override + public Stream> streamByPage() { + return pageIterable.streamByPage().map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken) { + return pageIterable.streamByPage(continuationToken).map(pageMapper); + } + + @Override + public Stream> streamByPage(int preferredPageSize) { + return pageIterable.streamByPage(preferredPageSize).map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken, int preferredPageSize) { + return pageIterable.streamByPage(continuationToken, preferredPageSize).map(pageMapper); + } + + @Override + public Iterator iterator() { + return new IteratorImpl(pageIterable.iterator(), mapper); + } + + @Override + public Iterable> iterableByPage() { + return new IterableImpl, PagedResponse>(pageIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl, PagedResponse>( + pageIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl, PagedResponse>( + pageIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl, PagedResponse>( + pageIterable.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/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/models/Cluster.java b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/models/Cluster.java index b547f4c0c56ea..82bbebbaa4297 100644 --- a/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/models/Cluster.java +++ b/sdk/kusto/azure-resourcemanager-kusto/src/main/java/com/azure/resourcemanager/kusto/models/Cluster.java @@ -4,9 +4,11 @@ package com.azure.resourcemanager.kusto.models; +import com.azure.core.http.rest.PagedIterable; import com.azure.core.management.Region; import com.azure.core.util.Context; import com.azure.resourcemanager.kusto.fluent.models.ClusterInner; +import com.azure.resourcemanager.kusto.fluent.models.FollowerDatabaseDefinitionInner; import java.util.List; import java.util.Map; @@ -577,4 +579,163 @@ interface WithEngineType { * @return the refreshed resource. */ Cluster refresh(Context context); + + /** + * Stops a Kusto cluster. + * + * @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 stop(); + + /** + * Stops a Kusto cluster. + * + * @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 stop(Context context); + + /** + * Starts a Kusto cluster. + * + * @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 start(); + + /** + * Starts a Kusto cluster. + * + * @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 start(Context context); + + /** + * Returns a list of databases that are owned by this cluster and were followed by another cluster. + * + * @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 list Kusto database principals operation response. + */ + PagedIterable listFollowerDatabases(); + + /** + * Returns a list of databases that are owned by this cluster and were followed by another cluster. + * + * @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 list Kusto database principals operation response. + */ + PagedIterable listFollowerDatabases(Context context); + + /** + * Detaches all followers of a database owned by this cluster. + * + * @param followerDatabaseToRemove The follower databases properties to remove. + * @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 detachFollowerDatabases(FollowerDatabaseDefinitionInner followerDatabaseToRemove); + + /** + * Detaches all followers of a database owned by this cluster. + * + * @param followerDatabaseToRemove The follower databases properties to remove. + * @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 detachFollowerDatabases(FollowerDatabaseDefinitionInner followerDatabaseToRemove, Context context); + + /** + * Diagnoses network connectivity status for external resources on which the service is dependent on. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + DiagnoseVirtualNetworkResult diagnoseVirtualNetwork(); + + /** + * Diagnoses network connectivity status for external resources on which the service is dependent on. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + DiagnoseVirtualNetworkResult diagnoseVirtualNetwork(Context context); + + /** + * Returns a list of language extensions that can run within KQL queries. + * + * @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 list of language extension objects. + */ + PagedIterable listLanguageExtensions(); + + /** + * Returns a list of language extensions that can run within KQL queries. + * + * @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 list of language extension objects. + */ + PagedIterable listLanguageExtensions(Context context); + + /** + * Add a list of language extensions that can run within KQL queries. + * + * @param languageExtensionsToAdd The language extensions to add. + * @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 addLanguageExtensions(LanguageExtensionsList languageExtensionsToAdd); + + /** + * Add a list of language extensions that can run within KQL queries. + * + * @param languageExtensionsToAdd The language extensions to add. + * @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 addLanguageExtensions(LanguageExtensionsList languageExtensionsToAdd, Context context); + + /** + * Remove a list of language extensions that can run within KQL queries. + * + * @param languageExtensionsToRemove The language extensions to remove. + * @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 removeLanguageExtensions(LanguageExtensionsList languageExtensionsToRemove); + + /** + * Remove a list of language extensions that can run within KQL queries. + * + * @param languageExtensionsToRemove The language extensions to remove. + * @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 removeLanguageExtensions(LanguageExtensionsList languageExtensionsToRemove, Context context); }