diff --git a/azure-mgmt-sql/src/main/java/com/microsoft/azure/management/sql/implementation/DatabaseVulnerabilityAssessmentInner.java b/azure-mgmt-sql/src/main/java/com/microsoft/azure/management/sql/implementation/DatabaseVulnerabilityAssessmentInner.java index d29a95cc0e0..98d5b983105 100644 --- a/azure-mgmt-sql/src/main/java/com/microsoft/azure/management/sql/implementation/DatabaseVulnerabilityAssessmentInner.java +++ b/azure-mgmt-sql/src/main/java/com/microsoft/azure/management/sql/implementation/DatabaseVulnerabilityAssessmentInner.java @@ -21,14 +21,14 @@ public class DatabaseVulnerabilityAssessmentInner extends ProxyResourceInner { * A blob storage container path to hold the scan results (e.g. * https://myStorage.blob.core.windows.net/VaScans/). */ - @JsonProperty(value = "properties.storageContainerPath") + @JsonProperty(value = "properties.storageContainerPath", required = true) private String storageContainerPath; /** * A shared access signature (SAS Key) that has write access to the blob * container specified in 'storageContainerPath' parameter. */ - @JsonProperty(value = "properties.storageContainerSasKey") + @JsonProperty(value = "properties.storageContainerSasKey", required = true) private String storageContainerSasKey; /** diff --git a/azure-mgmt-sql/src/main/java/com/microsoft/azure/management/sql/implementation/DatabaseVulnerabilityAssessmentScansInner.java b/azure-mgmt-sql/src/main/java/com/microsoft/azure/management/sql/implementation/DatabaseVulnerabilityAssessmentScansInner.java index 57f6040d72d..7f12f369011 100644 --- a/azure-mgmt-sql/src/main/java/com/microsoft/azure/management/sql/implementation/DatabaseVulnerabilityAssessmentScansInner.java +++ b/azure-mgmt-sql/src/main/java/com/microsoft/azure/management/sql/implementation/DatabaseVulnerabilityAssessmentScansInner.java @@ -62,13 +62,13 @@ interface DatabaseVulnerabilityAssessmentScansService { @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}") Observable> get(@Path("resourceGroupName") String resourceGroupName, @Path("serverName") String serverName, @Path("databaseName") String databaseName, @Path("vulnerabilityAssessmentName") String vulnerabilityAssessmentName, @Path("scanId") String scanId, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.sql.DatabaseVulnerabilityAssessmentScans execute" }) + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.sql.DatabaseVulnerabilityAssessmentScans initiateScan" }) @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan") - Observable> execute(@Path("resourceGroupName") String resourceGroupName, @Path("serverName") String serverName, @Path("databaseName") String databaseName, @Path("vulnerabilityAssessmentName") String vulnerabilityAssessmentName, @Path("scanId") String scanId, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> initiateScan(@Path("resourceGroupName") String resourceGroupName, @Path("serverName") String serverName, @Path("databaseName") String databaseName, @Path("vulnerabilityAssessmentName") String vulnerabilityAssessmentName, @Path("scanId") String scanId, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.sql.DatabaseVulnerabilityAssessmentScans beginExecute" }) + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.sql.DatabaseVulnerabilityAssessmentScans beginInitiateScan" }) @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan") - Observable> beginExecute(@Path("resourceGroupName") String resourceGroupName, @Path("serverName") String serverName, @Path("databaseName") String databaseName, @Path("vulnerabilityAssessmentName") String vulnerabilityAssessmentName, @Path("scanId") String scanId, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> beginInitiateScan(@Path("resourceGroupName") String resourceGroupName, @Path("serverName") String serverName, @Path("databaseName") String databaseName, @Path("vulnerabilityAssessmentName") String vulnerabilityAssessmentName, @Path("scanId") String scanId, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.sql.DatabaseVulnerabilityAssessmentScans listByDatabase" }) @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans") @@ -194,8 +194,8 @@ private ServiceResponse getDelegate(Resp * @throws CloudException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ - public void execute(String resourceGroupName, String serverName, String databaseName, String scanId) { - executeWithServiceResponseAsync(resourceGroupName, serverName, databaseName, scanId).toBlocking().last().body(); + public void initiateScan(String resourceGroupName, String serverName, String databaseName, String scanId) { + initiateScanWithServiceResponseAsync(resourceGroupName, serverName, databaseName, scanId).toBlocking().last().body(); } /** @@ -209,8 +209,8 @@ public void execute(String resourceGroupName, String serverName, String database * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ - public ServiceFuture executeAsync(String resourceGroupName, String serverName, String databaseName, String scanId, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(executeWithServiceResponseAsync(resourceGroupName, serverName, databaseName, scanId), serviceCallback); + public ServiceFuture initiateScanAsync(String resourceGroupName, String serverName, String databaseName, String scanId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(initiateScanWithServiceResponseAsync(resourceGroupName, serverName, databaseName, scanId), serviceCallback); } /** @@ -223,8 +223,8 @@ public ServiceFuture executeAsync(String resourceGroupName, String serverN * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable for the request */ - public Observable executeAsync(String resourceGroupName, String serverName, String databaseName, String scanId) { - return executeWithServiceResponseAsync(resourceGroupName, serverName, databaseName, scanId).map(new Func1, Void>() { + public Observable initiateScanAsync(String resourceGroupName, String serverName, String databaseName, String scanId) { + return initiateScanWithServiceResponseAsync(resourceGroupName, serverName, databaseName, scanId).map(new Func1, Void>() { @Override public Void call(ServiceResponse response) { return response.body(); @@ -242,7 +242,7 @@ public Void call(ServiceResponse response) { * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable for the request */ - public Observable> executeWithServiceResponseAsync(String resourceGroupName, String serverName, String databaseName, String scanId) { + public Observable> initiateScanWithServiceResponseAsync(String resourceGroupName, String serverName, String databaseName, String scanId) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } @@ -260,7 +260,7 @@ public Observable> executeWithServiceResponseAsync(String } final String vulnerabilityAssessmentName = "default"; final String apiVersion = "2017-10-01-preview"; - Observable> observable = service.execute(resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName, scanId, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent()); + Observable> observable = service.initiateScan(resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName, scanId, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent()); return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken() { }.getType()); } @@ -275,8 +275,8 @@ public Observable> executeWithServiceResponseAsync(String * @throws CloudException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ - public void beginExecute(String resourceGroupName, String serverName, String databaseName, String scanId) { - beginExecuteWithServiceResponseAsync(resourceGroupName, serverName, databaseName, scanId).toBlocking().single().body(); + public void beginInitiateScan(String resourceGroupName, String serverName, String databaseName, String scanId) { + beginInitiateScanWithServiceResponseAsync(resourceGroupName, serverName, databaseName, scanId).toBlocking().single().body(); } /** @@ -290,8 +290,8 @@ public void beginExecute(String resourceGroupName, String serverName, String dat * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ - public ServiceFuture beginExecuteAsync(String resourceGroupName, String serverName, String databaseName, String scanId, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(beginExecuteWithServiceResponseAsync(resourceGroupName, serverName, databaseName, scanId), serviceCallback); + public ServiceFuture beginInitiateScanAsync(String resourceGroupName, String serverName, String databaseName, String scanId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(beginInitiateScanWithServiceResponseAsync(resourceGroupName, serverName, databaseName, scanId), serviceCallback); } /** @@ -304,8 +304,8 @@ public ServiceFuture beginExecuteAsync(String resourceGroupName, String se * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ - public Observable beginExecuteAsync(String resourceGroupName, String serverName, String databaseName, String scanId) { - return beginExecuteWithServiceResponseAsync(resourceGroupName, serverName, databaseName, scanId).map(new Func1, Void>() { + public Observable beginInitiateScanAsync(String resourceGroupName, String serverName, String databaseName, String scanId) { + return beginInitiateScanWithServiceResponseAsync(resourceGroupName, serverName, databaseName, scanId).map(new Func1, Void>() { @Override public Void call(ServiceResponse response) { return response.body(); @@ -323,7 +323,7 @@ public Void call(ServiceResponse response) { * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ - public Observable> beginExecuteWithServiceResponseAsync(String resourceGroupName, String serverName, String databaseName, String scanId) { + public Observable> beginInitiateScanWithServiceResponseAsync(String resourceGroupName, String serverName, String databaseName, String scanId) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } @@ -341,12 +341,12 @@ public Observable> beginExecuteWithServiceResponseAsync(St } final String vulnerabilityAssessmentName = "default"; final String apiVersion = "2017-10-01-preview"; - return service.beginExecute(resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName, scanId, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent()) + return service.beginInitiateScan(resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName, scanId, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { try { - ServiceResponse clientResponse = beginExecuteDelegate(response); + ServiceResponse clientResponse = beginInitiateScanDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -355,7 +355,7 @@ public Observable> call(Response response) { }); } - private ServiceResponse beginExecuteDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + private ServiceResponse beginInitiateScanDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .register(202, new TypeToken() { }.getType()) diff --git a/azure-mgmt-sql/src/main/java/com/microsoft/azure/management/sql/implementation/ManagedDatabaseVulnerabilityAssessmentRuleBaselinesInner.java b/azure-mgmt-sql/src/main/java/com/microsoft/azure/management/sql/implementation/ManagedDatabaseVulnerabilityAssessmentRuleBaselinesInner.java new file mode 100644 index 00000000000..2814847ec9a --- /dev/null +++ b/azure-mgmt-sql/src/main/java/com/microsoft/azure/management/sql/implementation/ManagedDatabaseVulnerabilityAssessmentRuleBaselinesInner.java @@ -0,0 +1,383 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.sql.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.CloudException; +import com.microsoft.azure.management.sql.DatabaseVulnerabilityAssessmentRuleBaselineItem; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.Path; +import retrofit2.http.PUT; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in ManagedDatabaseVulnerabilityAssessmentRuleBaselines. + */ +public class ManagedDatabaseVulnerabilityAssessmentRuleBaselinesInner { + /** The Retrofit service to perform REST calls. */ + private ManagedDatabaseVulnerabilityAssessmentRuleBaselinesService service; + /** The service client containing this operation class. */ + private SqlManagementClientImpl client; + + /** + * Initializes an instance of ManagedDatabaseVulnerabilityAssessmentRuleBaselinesInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public ManagedDatabaseVulnerabilityAssessmentRuleBaselinesInner(Retrofit retrofit, SqlManagementClientImpl client) { + this.service = retrofit.create(ManagedDatabaseVulnerabilityAssessmentRuleBaselinesService.class); + this.client = client; + } + + /** + * The interface defining all the services for ManagedDatabaseVulnerabilityAssessmentRuleBaselines to be + * used by Retrofit to perform actually REST calls. + */ + interface ManagedDatabaseVulnerabilityAssessmentRuleBaselinesService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselines get" }) + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}") + Observable> get(@Path("resourceGroupName") String resourceGroupName, @Path("managedInstanceName") String managedInstanceName, @Path("databaseName") String databaseName, @Path("vulnerabilityAssessmentName") String vulnerabilityAssessmentName, @Path("ruleId") String ruleId, @Path("baselineName") String baselineName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselines createOrUpdate" }) + @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}") + Observable> createOrUpdate(@Path("resourceGroupName") String resourceGroupName, @Path("managedInstanceName") String managedInstanceName, @Path("databaseName") String databaseName, @Path("vulnerabilityAssessmentName") String vulnerabilityAssessmentName, @Path("ruleId") String ruleId, @Path("baselineName") String baselineName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body DatabaseVulnerabilityAssessmentRuleBaselineInner parameters, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselines delete" }) + @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", method = "DELETE", hasBody = true) + Observable> delete(@Path("resourceGroupName") String resourceGroupName, @Path("managedInstanceName") String managedInstanceName, @Path("databaseName") String databaseName, @Path("vulnerabilityAssessmentName") String vulnerabilityAssessmentName, @Path("ruleId") String ruleId, @Path("baselineName") String baselineName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Gets a database's vulnerability assessment rule baseline. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment rule baseline is defined. + * @param ruleId The vulnerability assessment rule ID. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the DatabaseVulnerabilityAssessmentRuleBaselineInner object if successful. + */ + public DatabaseVulnerabilityAssessmentRuleBaselineInner get(String resourceGroupName, String managedInstanceName, String databaseName, String ruleId) { + return getWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, ruleId).toBlocking().single().body(); + } + + /** + * Gets a database's vulnerability assessment rule baseline. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment rule baseline is defined. + * @param ruleId The vulnerability assessment rule ID. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getAsync(String resourceGroupName, String managedInstanceName, String databaseName, String ruleId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, ruleId), serviceCallback); + } + + /** + * Gets a database's vulnerability assessment rule baseline. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment rule baseline is defined. + * @param ruleId The vulnerability assessment rule ID. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the DatabaseVulnerabilityAssessmentRuleBaselineInner object + */ + public Observable getAsync(String resourceGroupName, String managedInstanceName, String databaseName, String ruleId) { + return getWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, ruleId).map(new Func1, DatabaseVulnerabilityAssessmentRuleBaselineInner>() { + @Override + public DatabaseVulnerabilityAssessmentRuleBaselineInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Gets a database's vulnerability assessment rule baseline. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment rule baseline is defined. + * @param ruleId The vulnerability assessment rule ID. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the DatabaseVulnerabilityAssessmentRuleBaselineInner object + */ + public Observable> getWithServiceResponseAsync(String resourceGroupName, String managedInstanceName, String databaseName, String ruleId) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (managedInstanceName == null) { + throw new IllegalArgumentException("Parameter managedInstanceName is required and cannot be null."); + } + if (databaseName == null) { + throw new IllegalArgumentException("Parameter databaseName is required and cannot be null."); + } + if (ruleId == null) { + throw new IllegalArgumentException("Parameter ruleId is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + final String vulnerabilityAssessmentName = "default"; + final String baselineName = "default"; + final String apiVersion = "2017-10-01-preview"; + return service.get(resourceGroupName, managedInstanceName, databaseName, vulnerabilityAssessmentName, ruleId, baselineName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Creates or updates a database's vulnerability assessment rule baseline. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment rule baseline is defined. + * @param ruleId The vulnerability assessment rule ID. + * @param baselineResults The rule baseline result + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the DatabaseVulnerabilityAssessmentRuleBaselineInner object if successful. + */ + public DatabaseVulnerabilityAssessmentRuleBaselineInner createOrUpdate(String resourceGroupName, String managedInstanceName, String databaseName, String ruleId, List baselineResults) { + return createOrUpdateWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, ruleId, baselineResults).toBlocking().single().body(); + } + + /** + * Creates or updates a database's vulnerability assessment rule baseline. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment rule baseline is defined. + * @param ruleId The vulnerability assessment rule ID. + * @param baselineResults The rule baseline result + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createOrUpdateAsync(String resourceGroupName, String managedInstanceName, String databaseName, String ruleId, List baselineResults, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createOrUpdateWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, ruleId, baselineResults), serviceCallback); + } + + /** + * Creates or updates a database's vulnerability assessment rule baseline. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment rule baseline is defined. + * @param ruleId The vulnerability assessment rule ID. + * @param baselineResults The rule baseline result + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the DatabaseVulnerabilityAssessmentRuleBaselineInner object + */ + public Observable createOrUpdateAsync(String resourceGroupName, String managedInstanceName, String databaseName, String ruleId, List baselineResults) { + return createOrUpdateWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, ruleId, baselineResults).map(new Func1, DatabaseVulnerabilityAssessmentRuleBaselineInner>() { + @Override + public DatabaseVulnerabilityAssessmentRuleBaselineInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Creates or updates a database's vulnerability assessment rule baseline. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment rule baseline is defined. + * @param ruleId The vulnerability assessment rule ID. + * @param baselineResults The rule baseline result + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the DatabaseVulnerabilityAssessmentRuleBaselineInner object + */ + public Observable> createOrUpdateWithServiceResponseAsync(String resourceGroupName, String managedInstanceName, String databaseName, String ruleId, List baselineResults) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (managedInstanceName == null) { + throw new IllegalArgumentException("Parameter managedInstanceName is required and cannot be null."); + } + if (databaseName == null) { + throw new IllegalArgumentException("Parameter databaseName is required and cannot be null."); + } + if (ruleId == null) { + throw new IllegalArgumentException("Parameter ruleId is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (baselineResults == null) { + throw new IllegalArgumentException("Parameter baselineResults is required and cannot be null."); + } + Validator.validate(baselineResults); + final String vulnerabilityAssessmentName = "default"; + final String baselineName = "default"; + final String apiVersion = "2017-10-01-preview"; + DatabaseVulnerabilityAssessmentRuleBaselineInner parameters = new DatabaseVulnerabilityAssessmentRuleBaselineInner(); + parameters.withBaselineResults(baselineResults); + return service.createOrUpdate(resourceGroupName, managedInstanceName, databaseName, vulnerabilityAssessmentName, ruleId, baselineName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), parameters, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createOrUpdateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createOrUpdateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Removes the database's vulnerability assessment rule baseline. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment rule baseline is defined. + * @param ruleId The vulnerability assessment rule ID. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void delete(String resourceGroupName, String managedInstanceName, String databaseName, String ruleId) { + deleteWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, ruleId).toBlocking().single().body(); + } + + /** + * Removes the database's vulnerability assessment rule baseline. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment rule baseline is defined. + * @param ruleId The vulnerability assessment rule ID. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture deleteAsync(String resourceGroupName, String managedInstanceName, String databaseName, String ruleId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, ruleId), serviceCallback); + } + + /** + * Removes the database's vulnerability assessment rule baseline. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment rule baseline is defined. + * @param ruleId The vulnerability assessment rule ID. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAsync(String resourceGroupName, String managedInstanceName, String databaseName, String ruleId) { + return deleteWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, ruleId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Removes the database's vulnerability assessment rule baseline. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment rule baseline is defined. + * @param ruleId The vulnerability assessment rule ID. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteWithServiceResponseAsync(String resourceGroupName, String managedInstanceName, String databaseName, String ruleId) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (managedInstanceName == null) { + throw new IllegalArgumentException("Parameter managedInstanceName is required and cannot be null."); + } + if (databaseName == null) { + throw new IllegalArgumentException("Parameter databaseName is required and cannot be null."); + } + if (ruleId == null) { + throw new IllegalArgumentException("Parameter ruleId is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + final String vulnerabilityAssessmentName = "default"; + final String baselineName = "default"; + final String apiVersion = "2017-10-01-preview"; + return service.delete(resourceGroupName, managedInstanceName, databaseName, vulnerabilityAssessmentName, ruleId, baselineName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + +} diff --git a/azure-mgmt-sql/src/main/java/com/microsoft/azure/management/sql/implementation/ManagedDatabaseVulnerabilityAssessmentScansInner.java b/azure-mgmt-sql/src/main/java/com/microsoft/azure/management/sql/implementation/ManagedDatabaseVulnerabilityAssessmentScansInner.java new file mode 100644 index 00000000000..1c206318727 --- /dev/null +++ b/azure-mgmt-sql/src/main/java/com/microsoft/azure/management/sql/implementation/ManagedDatabaseVulnerabilityAssessmentScansInner.java @@ -0,0 +1,707 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.sql.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceFuture; +import com.microsoft.azure.CloudException; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.POST; +import retrofit2.http.Query; +import retrofit2.http.Url; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in ManagedDatabaseVulnerabilityAssessmentScans. + */ +public class ManagedDatabaseVulnerabilityAssessmentScansInner { + /** The Retrofit service to perform REST calls. */ + private ManagedDatabaseVulnerabilityAssessmentScansService service; + /** The service client containing this operation class. */ + private SqlManagementClientImpl client; + + /** + * Initializes an instance of ManagedDatabaseVulnerabilityAssessmentScansInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public ManagedDatabaseVulnerabilityAssessmentScansInner(Retrofit retrofit, SqlManagementClientImpl client) { + this.service = retrofit.create(ManagedDatabaseVulnerabilityAssessmentScansService.class); + this.client = client; + } + + /** + * The interface defining all the services for ManagedDatabaseVulnerabilityAssessmentScans to be + * used by Retrofit to perform actually REST calls. + */ + interface ManagedDatabaseVulnerabilityAssessmentScansService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.sql.ManagedDatabaseVulnerabilityAssessmentScans listByDatabase" }) + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans") + Observable> listByDatabase(@Path("resourceGroupName") String resourceGroupName, @Path("managedInstanceName") String managedInstanceName, @Path("databaseName") String databaseName, @Path("vulnerabilityAssessmentName") String vulnerabilityAssessmentName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.sql.ManagedDatabaseVulnerabilityAssessmentScans get" }) + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}") + Observable> get(@Path("resourceGroupName") String resourceGroupName, @Path("managedInstanceName") String managedInstanceName, @Path("databaseName") String databaseName, @Path("vulnerabilityAssessmentName") String vulnerabilityAssessmentName, @Path("scanId") String scanId, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.sql.ManagedDatabaseVulnerabilityAssessmentScans initiateScan" }) + @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan") + Observable> initiateScan(@Path("resourceGroupName") String resourceGroupName, @Path("managedInstanceName") String managedInstanceName, @Path("databaseName") String databaseName, @Path("vulnerabilityAssessmentName") String vulnerabilityAssessmentName, @Path("scanId") String scanId, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.sql.ManagedDatabaseVulnerabilityAssessmentScans beginInitiateScan" }) + @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan") + Observable> beginInitiateScan(@Path("resourceGroupName") String resourceGroupName, @Path("managedInstanceName") String managedInstanceName, @Path("databaseName") String databaseName, @Path("vulnerabilityAssessmentName") String vulnerabilityAssessmentName, @Path("scanId") String scanId, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.sql.ManagedDatabaseVulnerabilityAssessmentScans export" }) + @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export") + Observable> export(@Path("resourceGroupName") String resourceGroupName, @Path("managedInstanceName") String managedInstanceName, @Path("databaseName") String databaseName, @Path("vulnerabilityAssessmentName") String vulnerabilityAssessmentName, @Path("scanId") String scanId, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.sql.ManagedDatabaseVulnerabilityAssessmentScans listByDatabaseNext" }) + @GET + Observable> listByDatabaseNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Lists the vulnerability assessment scans of a database. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<VulnerabilityAssessmentScanRecordInner> object if successful. + */ + public PagedList listByDatabase(final String resourceGroupName, final String managedInstanceName, final String databaseName) { + ServiceResponse> response = listByDatabaseSinglePageAsync(resourceGroupName, managedInstanceName, databaseName).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByDatabaseNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the vulnerability assessment scans of a database. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByDatabaseAsync(final String resourceGroupName, final String managedInstanceName, final String databaseName, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByDatabaseSinglePageAsync(resourceGroupName, managedInstanceName, databaseName), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByDatabaseNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the vulnerability assessment scans of a database. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<VulnerabilityAssessmentScanRecordInner> object + */ + public Observable> listByDatabaseAsync(final String resourceGroupName, final String managedInstanceName, final String databaseName) { + return listByDatabaseWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the vulnerability assessment scans of a database. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<VulnerabilityAssessmentScanRecordInner> object + */ + public Observable>> listByDatabaseWithServiceResponseAsync(final String resourceGroupName, final String managedInstanceName, final String databaseName) { + return listByDatabaseSinglePageAsync(resourceGroupName, managedInstanceName, databaseName) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByDatabaseNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the vulnerability assessment scans of a database. + * + ServiceResponse> * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + ServiceResponse> * @param managedInstanceName The name of the managed instance. + ServiceResponse> * @param databaseName The name of the database. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<VulnerabilityAssessmentScanRecordInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByDatabaseSinglePageAsync(final String resourceGroupName, final String managedInstanceName, final String databaseName) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (managedInstanceName == null) { + throw new IllegalArgumentException("Parameter managedInstanceName is required and cannot be null."); + } + if (databaseName == null) { + throw new IllegalArgumentException("Parameter databaseName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + final String vulnerabilityAssessmentName = "default"; + final String apiVersion = "2017-10-01-preview"; + return service.listByDatabase(resourceGroupName, managedInstanceName, databaseName, vulnerabilityAssessmentName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByDatabaseDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByDatabaseDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., CloudException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Gets a vulnerability assessment scan record of a database. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database. + * @param scanId The vulnerability assessment scan Id of the scan to retrieve. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the VulnerabilityAssessmentScanRecordInner object if successful. + */ + public VulnerabilityAssessmentScanRecordInner get(String resourceGroupName, String managedInstanceName, String databaseName, String scanId) { + return getWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, scanId).toBlocking().single().body(); + } + + /** + * Gets a vulnerability assessment scan record of a database. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database. + * @param scanId The vulnerability assessment scan Id of the scan to retrieve. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getAsync(String resourceGroupName, String managedInstanceName, String databaseName, String scanId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, scanId), serviceCallback); + } + + /** + * Gets a vulnerability assessment scan record of a database. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database. + * @param scanId The vulnerability assessment scan Id of the scan to retrieve. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the VulnerabilityAssessmentScanRecordInner object + */ + public Observable getAsync(String resourceGroupName, String managedInstanceName, String databaseName, String scanId) { + return getWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, scanId).map(new Func1, VulnerabilityAssessmentScanRecordInner>() { + @Override + public VulnerabilityAssessmentScanRecordInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Gets a vulnerability assessment scan record of a database. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database. + * @param scanId The vulnerability assessment scan Id of the scan to retrieve. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the VulnerabilityAssessmentScanRecordInner object + */ + public Observable> getWithServiceResponseAsync(String resourceGroupName, String managedInstanceName, String databaseName, String scanId) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (managedInstanceName == null) { + throw new IllegalArgumentException("Parameter managedInstanceName is required and cannot be null."); + } + if (databaseName == null) { + throw new IllegalArgumentException("Parameter databaseName is required and cannot be null."); + } + if (scanId == null) { + throw new IllegalArgumentException("Parameter scanId is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + final String vulnerabilityAssessmentName = "default"; + final String apiVersion = "2017-10-01-preview"; + return service.get(resourceGroupName, managedInstanceName, databaseName, vulnerabilityAssessmentName, scanId, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Executes a Vulnerability Assessment database scan. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database. + * @param scanId The vulnerability assessment scan Id of the scan to retrieve. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void initiateScan(String resourceGroupName, String managedInstanceName, String databaseName, String scanId) { + initiateScanWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, scanId).toBlocking().last().body(); + } + + /** + * Executes a Vulnerability Assessment database scan. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database. + * @param scanId The vulnerability assessment scan Id of the scan to retrieve. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture initiateScanAsync(String resourceGroupName, String managedInstanceName, String databaseName, String scanId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(initiateScanWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, scanId), serviceCallback); + } + + /** + * Executes a Vulnerability Assessment database scan. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database. + * @param scanId The vulnerability assessment scan Id of the scan to retrieve. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + public Observable initiateScanAsync(String resourceGroupName, String managedInstanceName, String databaseName, String scanId) { + return initiateScanWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, scanId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Executes a Vulnerability Assessment database scan. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database. + * @param scanId The vulnerability assessment scan Id of the scan to retrieve. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + public Observable> initiateScanWithServiceResponseAsync(String resourceGroupName, String managedInstanceName, String databaseName, String scanId) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (managedInstanceName == null) { + throw new IllegalArgumentException("Parameter managedInstanceName is required and cannot be null."); + } + if (databaseName == null) { + throw new IllegalArgumentException("Parameter databaseName is required and cannot be null."); + } + if (scanId == null) { + throw new IllegalArgumentException("Parameter scanId is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + final String vulnerabilityAssessmentName = "default"; + final String apiVersion = "2017-10-01-preview"; + Observable> observable = service.initiateScan(resourceGroupName, managedInstanceName, databaseName, vulnerabilityAssessmentName, scanId, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent()); + return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken() { }.getType()); + } + + /** + * Executes a Vulnerability Assessment database scan. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database. + * @param scanId The vulnerability assessment scan Id of the scan to retrieve. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void beginInitiateScan(String resourceGroupName, String managedInstanceName, String databaseName, String scanId) { + beginInitiateScanWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, scanId).toBlocking().single().body(); + } + + /** + * Executes a Vulnerability Assessment database scan. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database. + * @param scanId The vulnerability assessment scan Id of the scan to retrieve. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture beginInitiateScanAsync(String resourceGroupName, String managedInstanceName, String databaseName, String scanId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(beginInitiateScanWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, scanId), serviceCallback); + } + + /** + * Executes a Vulnerability Assessment database scan. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database. + * @param scanId The vulnerability assessment scan Id of the scan to retrieve. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable beginInitiateScanAsync(String resourceGroupName, String managedInstanceName, String databaseName, String scanId) { + return beginInitiateScanWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, scanId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Executes a Vulnerability Assessment database scan. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database. + * @param scanId The vulnerability assessment scan Id of the scan to retrieve. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> beginInitiateScanWithServiceResponseAsync(String resourceGroupName, String managedInstanceName, String databaseName, String scanId) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (managedInstanceName == null) { + throw new IllegalArgumentException("Parameter managedInstanceName is required and cannot be null."); + } + if (databaseName == null) { + throw new IllegalArgumentException("Parameter databaseName is required and cannot be null."); + } + if (scanId == null) { + throw new IllegalArgumentException("Parameter scanId is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + final String vulnerabilityAssessmentName = "default"; + final String apiVersion = "2017-10-01-preview"; + return service.beginInitiateScan(resourceGroupName, managedInstanceName, databaseName, vulnerabilityAssessmentName, scanId, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = beginInitiateScanDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse beginInitiateScanDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(202, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Convert an existing scan result to a human readable format. If already exists nothing happens. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the scanned database. + * @param scanId The vulnerability assessment scan Id. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the DatabaseVulnerabilityAssessmentScansExportInner object if successful. + */ + public DatabaseVulnerabilityAssessmentScansExportInner export(String resourceGroupName, String managedInstanceName, String databaseName, String scanId) { + return exportWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, scanId).toBlocking().single().body(); + } + + /** + * Convert an existing scan result to a human readable format. If already exists nothing happens. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the scanned database. + * @param scanId The vulnerability assessment scan Id. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture exportAsync(String resourceGroupName, String managedInstanceName, String databaseName, String scanId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(exportWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, scanId), serviceCallback); + } + + /** + * Convert an existing scan result to a human readable format. If already exists nothing happens. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the scanned database. + * @param scanId The vulnerability assessment scan Id. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the DatabaseVulnerabilityAssessmentScansExportInner object + */ + public Observable exportAsync(String resourceGroupName, String managedInstanceName, String databaseName, String scanId) { + return exportWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, scanId).map(new Func1, DatabaseVulnerabilityAssessmentScansExportInner>() { + @Override + public DatabaseVulnerabilityAssessmentScansExportInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Convert an existing scan result to a human readable format. If already exists nothing happens. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the scanned database. + * @param scanId The vulnerability assessment scan Id. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the DatabaseVulnerabilityAssessmentScansExportInner object + */ + public Observable> exportWithServiceResponseAsync(String resourceGroupName, String managedInstanceName, String databaseName, String scanId) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (managedInstanceName == null) { + throw new IllegalArgumentException("Parameter managedInstanceName is required and cannot be null."); + } + if (databaseName == null) { + throw new IllegalArgumentException("Parameter databaseName is required and cannot be null."); + } + if (scanId == null) { + throw new IllegalArgumentException("Parameter scanId is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + final String vulnerabilityAssessmentName = "default"; + final String apiVersion = "2017-10-01-preview"; + return service.export(resourceGroupName, managedInstanceName, databaseName, vulnerabilityAssessmentName, scanId, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = exportDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse exportDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(201, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Lists the vulnerability assessment scans of a database. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PagedList<VulnerabilityAssessmentScanRecordInner> object if successful. + */ + public PagedList listByDatabaseNext(final String nextPageLink) { + ServiceResponse> response = listByDatabaseNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByDatabaseNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Lists the vulnerability assessment scans of a database. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceFuture the ServiceFuture object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByDatabaseNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByDatabaseNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByDatabaseNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Lists the vulnerability assessment scans of a database. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<VulnerabilityAssessmentScanRecordInner> object + */ + public Observable> listByDatabaseNextAsync(final String nextPageLink) { + return listByDatabaseNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the vulnerability assessment scans of a database. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<VulnerabilityAssessmentScanRecordInner> object + */ + public Observable>> listByDatabaseNextWithServiceResponseAsync(final String nextPageLink) { + return listByDatabaseNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listByDatabaseNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Lists the vulnerability assessment scans of a database. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<VulnerabilityAssessmentScanRecordInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByDatabaseNextSinglePageAsync(final String nextPageLink) { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + String nextUrl = String.format("%s", nextPageLink); + return service.listByDatabaseNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByDatabaseNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByDatabaseNextDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., CloudException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + +} diff --git a/azure-mgmt-sql/src/main/java/com/microsoft/azure/management/sql/implementation/ManagedDatabaseVulnerabilityAssessmentsInner.java b/azure-mgmt-sql/src/main/java/com/microsoft/azure/management/sql/implementation/ManagedDatabaseVulnerabilityAssessmentsInner.java new file mode 100644 index 00000000000..0fe5ec74c09 --- /dev/null +++ b/azure-mgmt-sql/src/main/java/com/microsoft/azure/management/sql/implementation/ManagedDatabaseVulnerabilityAssessmentsInner.java @@ -0,0 +1,356 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.sql.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.CloudException; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.IOException; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.Path; +import retrofit2.http.PUT; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in ManagedDatabaseVulnerabilityAssessments. + */ +public class ManagedDatabaseVulnerabilityAssessmentsInner { + /** The Retrofit service to perform REST calls. */ + private ManagedDatabaseVulnerabilityAssessmentsService service; + /** The service client containing this operation class. */ + private SqlManagementClientImpl client; + + /** + * Initializes an instance of ManagedDatabaseVulnerabilityAssessmentsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public ManagedDatabaseVulnerabilityAssessmentsInner(Retrofit retrofit, SqlManagementClientImpl client) { + this.service = retrofit.create(ManagedDatabaseVulnerabilityAssessmentsService.class); + this.client = client; + } + + /** + * The interface defining all the services for ManagedDatabaseVulnerabilityAssessments to be + * used by Retrofit to perform actually REST calls. + */ + interface ManagedDatabaseVulnerabilityAssessmentsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.sql.ManagedDatabaseVulnerabilityAssessments get" }) + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}") + Observable> get(@Path("resourceGroupName") String resourceGroupName, @Path("managedInstanceName") String managedInstanceName, @Path("databaseName") String databaseName, @Path("vulnerabilityAssessmentName") String vulnerabilityAssessmentName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.sql.ManagedDatabaseVulnerabilityAssessments createOrUpdate" }) + @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}") + Observable> createOrUpdate(@Path("resourceGroupName") String resourceGroupName, @Path("managedInstanceName") String managedInstanceName, @Path("databaseName") String databaseName, @Path("vulnerabilityAssessmentName") String vulnerabilityAssessmentName, @Path("subscriptionId") String subscriptionId, @Body DatabaseVulnerabilityAssessmentInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.sql.ManagedDatabaseVulnerabilityAssessments delete" }) + @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", method = "DELETE", hasBody = true) + Observable> delete(@Path("resourceGroupName") String resourceGroupName, @Path("managedInstanceName") String managedInstanceName, @Path("databaseName") String databaseName, @Path("vulnerabilityAssessmentName") String vulnerabilityAssessmentName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Gets the database's vulnerability assessment. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment is defined. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the DatabaseVulnerabilityAssessmentInner object if successful. + */ + public DatabaseVulnerabilityAssessmentInner get(String resourceGroupName, String managedInstanceName, String databaseName) { + return getWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName).toBlocking().single().body(); + } + + /** + * Gets the database's vulnerability assessment. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment is defined. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getAsync(String resourceGroupName, String managedInstanceName, String databaseName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName), serviceCallback); + } + + /** + * Gets the database's vulnerability assessment. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment is defined. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the DatabaseVulnerabilityAssessmentInner object + */ + public Observable getAsync(String resourceGroupName, String managedInstanceName, String databaseName) { + return getWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName).map(new Func1, DatabaseVulnerabilityAssessmentInner>() { + @Override + public DatabaseVulnerabilityAssessmentInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Gets the database's vulnerability assessment. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment is defined. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the DatabaseVulnerabilityAssessmentInner object + */ + public Observable> getWithServiceResponseAsync(String resourceGroupName, String managedInstanceName, String databaseName) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (managedInstanceName == null) { + throw new IllegalArgumentException("Parameter managedInstanceName is required and cannot be null."); + } + if (databaseName == null) { + throw new IllegalArgumentException("Parameter databaseName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + final String vulnerabilityAssessmentName = "default"; + final String apiVersion = "2017-10-01-preview"; + return service.get(resourceGroupName, managedInstanceName, databaseName, vulnerabilityAssessmentName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Creates or updates the database's vulnerability assessment. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment is defined. + * @param parameters The requested resource. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the DatabaseVulnerabilityAssessmentInner object if successful. + */ + public DatabaseVulnerabilityAssessmentInner createOrUpdate(String resourceGroupName, String managedInstanceName, String databaseName, DatabaseVulnerabilityAssessmentInner parameters) { + return createOrUpdateWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, parameters).toBlocking().single().body(); + } + + /** + * Creates or updates the database's vulnerability assessment. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment is defined. + * @param parameters The requested resource. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createOrUpdateAsync(String resourceGroupName, String managedInstanceName, String databaseName, DatabaseVulnerabilityAssessmentInner parameters, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createOrUpdateWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, parameters), serviceCallback); + } + + /** + * Creates or updates the database's vulnerability assessment. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment is defined. + * @param parameters The requested resource. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the DatabaseVulnerabilityAssessmentInner object + */ + public Observable createOrUpdateAsync(String resourceGroupName, String managedInstanceName, String databaseName, DatabaseVulnerabilityAssessmentInner parameters) { + return createOrUpdateWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName, parameters).map(new Func1, DatabaseVulnerabilityAssessmentInner>() { + @Override + public DatabaseVulnerabilityAssessmentInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Creates or updates the database's vulnerability assessment. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment is defined. + * @param parameters The requested resource. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the DatabaseVulnerabilityAssessmentInner object + */ + public Observable> createOrUpdateWithServiceResponseAsync(String resourceGroupName, String managedInstanceName, String databaseName, DatabaseVulnerabilityAssessmentInner parameters) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (managedInstanceName == null) { + throw new IllegalArgumentException("Parameter managedInstanceName is required and cannot be null."); + } + if (databaseName == null) { + throw new IllegalArgumentException("Parameter databaseName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + Validator.validate(parameters); + final String vulnerabilityAssessmentName = "default"; + final String apiVersion = "2017-10-01-preview"; + return service.createOrUpdate(resourceGroupName, managedInstanceName, databaseName, vulnerabilityAssessmentName, this.client.subscriptionId(), parameters, apiVersion, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createOrUpdateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createOrUpdateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(201, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Removes the database's vulnerability assessment. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment is defined. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void delete(String resourceGroupName, String managedInstanceName, String databaseName) { + deleteWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName).toBlocking().single().body(); + } + + /** + * Removes the database's vulnerability assessment. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment is defined. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture deleteAsync(String resourceGroupName, String managedInstanceName, String databaseName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName), serviceCallback); + } + + /** + * Removes the database's vulnerability assessment. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment is defined. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAsync(String resourceGroupName, String managedInstanceName, String databaseName) { + return deleteWithServiceResponseAsync(resourceGroupName, managedInstanceName, databaseName).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Removes the database's vulnerability assessment. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param managedInstanceName The name of the managed instance. + * @param databaseName The name of the database for which the vulnerability assessment is defined. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteWithServiceResponseAsync(String resourceGroupName, String managedInstanceName, String databaseName) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (managedInstanceName == null) { + throw new IllegalArgumentException("Parameter managedInstanceName is required and cannot be null."); + } + if (databaseName == null) { + throw new IllegalArgumentException("Parameter databaseName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + final String vulnerabilityAssessmentName = "default"; + final String apiVersion = "2017-10-01-preview"; + return service.delete(resourceGroupName, managedInstanceName, databaseName, vulnerabilityAssessmentName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + +} diff --git a/azure-mgmt-sql/src/main/java/com/microsoft/azure/management/sql/implementation/SqlManagementClientImpl.java b/azure-mgmt-sql/src/main/java/com/microsoft/azure/management/sql/implementation/SqlManagementClientImpl.java index 3510dace93e..308ca9785ef 100644 --- a/azure-mgmt-sql/src/main/java/com/microsoft/azure/management/sql/implementation/SqlManagementClientImpl.java +++ b/azure-mgmt-sql/src/main/java/com/microsoft/azure/management/sql/implementation/SqlManagementClientImpl.java @@ -848,6 +848,45 @@ public DatabaseVulnerabilityAssessmentScansInner databaseVulnerabilityAssessment return this.databaseVulnerabilityAssessmentScans; } + /** + * The ManagedDatabaseVulnerabilityAssessmentRuleBaselinesInner object to access its operations. + */ + private ManagedDatabaseVulnerabilityAssessmentRuleBaselinesInner managedDatabaseVulnerabilityAssessmentRuleBaselines; + + /** + * Gets the ManagedDatabaseVulnerabilityAssessmentRuleBaselinesInner object to access its operations. + * @return the ManagedDatabaseVulnerabilityAssessmentRuleBaselinesInner object. + */ + public ManagedDatabaseVulnerabilityAssessmentRuleBaselinesInner managedDatabaseVulnerabilityAssessmentRuleBaselines() { + return this.managedDatabaseVulnerabilityAssessmentRuleBaselines; + } + + /** + * The ManagedDatabaseVulnerabilityAssessmentsInner object to access its operations. + */ + private ManagedDatabaseVulnerabilityAssessmentsInner managedDatabaseVulnerabilityAssessments; + + /** + * Gets the ManagedDatabaseVulnerabilityAssessmentsInner object to access its operations. + * @return the ManagedDatabaseVulnerabilityAssessmentsInner object. + */ + public ManagedDatabaseVulnerabilityAssessmentsInner managedDatabaseVulnerabilityAssessments() { + return this.managedDatabaseVulnerabilityAssessments; + } + + /** + * The ManagedDatabaseVulnerabilityAssessmentScansInner object to access its operations. + */ + private ManagedDatabaseVulnerabilityAssessmentScansInner managedDatabaseVulnerabilityAssessmentScans; + + /** + * Gets the ManagedDatabaseVulnerabilityAssessmentScansInner object to access its operations. + * @return the ManagedDatabaseVulnerabilityAssessmentScansInner object. + */ + public ManagedDatabaseVulnerabilityAssessmentScansInner managedDatabaseVulnerabilityAssessmentScans() { + return this.managedDatabaseVulnerabilityAssessmentScans; + } + /** * The InstanceFailoverGroupsInner object to access its operations. */ @@ -964,6 +1003,9 @@ protected void initialize() { this.elasticPoolOperations = new ElasticPoolOperationsInner(restClient().retrofit(), this); this.capabilities = new CapabilitiesInner(restClient().retrofit(), this); this.databaseVulnerabilityAssessmentScans = new DatabaseVulnerabilityAssessmentScansInner(restClient().retrofit(), this); + this.managedDatabaseVulnerabilityAssessmentRuleBaselines = new ManagedDatabaseVulnerabilityAssessmentRuleBaselinesInner(restClient().retrofit(), this); + this.managedDatabaseVulnerabilityAssessments = new ManagedDatabaseVulnerabilityAssessmentsInner(restClient().retrofit(), this); + this.managedDatabaseVulnerabilityAssessmentScans = new ManagedDatabaseVulnerabilityAssessmentScansInner(restClient().retrofit(), this); this.instanceFailoverGroups = new InstanceFailoverGroupsInner(restClient().retrofit(), this); this.shortTermRetentionPolicies = new ShortTermRetentionPoliciesInner(restClient().retrofit(), this); this.azureClient = new AzureClient(this);