diff --git a/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/PerformanceTierServiceLevelObjectives.java b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/PerformanceTierServiceLevelObjectives.java index c5c2fecf31a..52f1370a9cc 100644 --- a/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/PerformanceTierServiceLevelObjectives.java +++ b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/PerformanceTierServiceLevelObjectives.java @@ -38,6 +38,30 @@ public class PerformanceTierServiceLevelObjectives { @JsonProperty(value = "hardwareGeneration") private String hardwareGeneration; + /** + * Maximum Backup retention in days for the performance tier edition. + */ + @JsonProperty(value = "maxBackupRetentionDays") + private Integer maxBackupRetentionDays; + + /** + * Minimum Backup retention in days for the performance tier edition. + */ + @JsonProperty(value = "minBackupRetentionDays") + private Integer minBackupRetentionDays; + + /** + * Max storage allowed for a server. + */ + @JsonProperty(value = "maxStorageMB") + private Integer maxStorageMB; + + /** + * Max storage allowed for a server. + */ + @JsonProperty(value = "minStorageMB") + private Integer minStorageMB; + /** * Get the id value. * @@ -118,4 +142,84 @@ public PerformanceTierServiceLevelObjectives withHardwareGeneration(String hardw return this; } + /** + * Get the maxBackupRetentionDays value. + * + * @return the maxBackupRetentionDays value + */ + public Integer maxBackupRetentionDays() { + return this.maxBackupRetentionDays; + } + + /** + * Set the maxBackupRetentionDays value. + * + * @param maxBackupRetentionDays the maxBackupRetentionDays value to set + * @return the PerformanceTierServiceLevelObjectives object itself. + */ + public PerformanceTierServiceLevelObjectives withMaxBackupRetentionDays(Integer maxBackupRetentionDays) { + this.maxBackupRetentionDays = maxBackupRetentionDays; + return this; + } + + /** + * Get the minBackupRetentionDays value. + * + * @return the minBackupRetentionDays value + */ + public Integer minBackupRetentionDays() { + return this.minBackupRetentionDays; + } + + /** + * Set the minBackupRetentionDays value. + * + * @param minBackupRetentionDays the minBackupRetentionDays value to set + * @return the PerformanceTierServiceLevelObjectives object itself. + */ + public PerformanceTierServiceLevelObjectives withMinBackupRetentionDays(Integer minBackupRetentionDays) { + this.minBackupRetentionDays = minBackupRetentionDays; + return this; + } + + /** + * Get the maxStorageMB value. + * + * @return the maxStorageMB value + */ + public Integer maxStorageMB() { + return this.maxStorageMB; + } + + /** + * Set the maxStorageMB value. + * + * @param maxStorageMB the maxStorageMB value to set + * @return the PerformanceTierServiceLevelObjectives object itself. + */ + public PerformanceTierServiceLevelObjectives withMaxStorageMB(Integer maxStorageMB) { + this.maxStorageMB = maxStorageMB; + return this; + } + + /** + * Get the minStorageMB value. + * + * @return the minStorageMB value + */ + public Integer minStorageMB() { + return this.minStorageMB; + } + + /** + * Set the minStorageMB value. + * + * @param minStorageMB the minStorageMB value to set + * @return the PerformanceTierServiceLevelObjectives object itself. + */ + public PerformanceTierServiceLevelObjectives withMinStorageMB(Integer minStorageMB) { + this.minStorageMB = minStorageMB; + return this; + } + } diff --git a/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/ServerPropertiesForCreate.java b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/ServerPropertiesForCreate.java index 47634e5a271..2e20a4e7f23 100644 --- a/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/ServerPropertiesForCreate.java +++ b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/ServerPropertiesForCreate.java @@ -20,7 +20,8 @@ @JsonTypeName("ServerPropertiesForCreate") @JsonSubTypes({ @JsonSubTypes.Type(name = "Default", value = ServerPropertiesForDefaultCreate.class), - @JsonSubTypes.Type(name = "PointInTimeRestore", value = ServerPropertiesForRestore.class) + @JsonSubTypes.Type(name = "PointInTimeRestore", value = ServerPropertiesForRestore.class), + @JsonSubTypes.Type(name = "GeoRestore", value = ServerPropertiesForGeoRestore.class) }) public class ServerPropertiesForCreate { /** diff --git a/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/ServerPropertiesForGeoRestore.java b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/ServerPropertiesForGeoRestore.java new file mode 100644 index 00000000000..c1b19a4d52b --- /dev/null +++ b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/ServerPropertiesForGeoRestore.java @@ -0,0 +1,48 @@ +/** + * 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.postgresql; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * The properties used to create a new server by restoring to a different + * region from a geo replicated backup. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "createMode") +@JsonTypeName("GeoRestore") +public class ServerPropertiesForGeoRestore extends ServerPropertiesForCreate { + /** + * The source server id to restore from. + */ + @JsonProperty(value = "sourceServerId", required = true) + private String sourceServerId; + + /** + * Get the sourceServerId value. + * + * @return the sourceServerId value + */ + public String sourceServerId() { + return this.sourceServerId; + } + + /** + * Set the sourceServerId value. + * + * @param sourceServerId the sourceServerId value to set + * @return the ServerPropertiesForGeoRestore object itself. + */ + public ServerPropertiesForGeoRestore withSourceServerId(String sourceServerId) { + this.sourceServerId = sourceServerId; + return this; + } + +} diff --git a/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/ServerPropertiesForRestore.java b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/ServerPropertiesForRestore.java index f8d2f2d94e6..2b44eef00d3 100644 --- a/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/ServerPropertiesForRestore.java +++ b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/ServerPropertiesForRestore.java @@ -14,7 +14,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName; /** - * The properties to a new server by restoring from a backup. + * The properties used to create a new server by restoring from a backup. */ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "createMode") @JsonTypeName("PointInTimeRestore") diff --git a/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/ServerSecurityAlertPolicyState.java b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/ServerSecurityAlertPolicyState.java new file mode 100644 index 00000000000..3f4894527ef --- /dev/null +++ b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/ServerSecurityAlertPolicyState.java @@ -0,0 +1,53 @@ +/** + * 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.postgresql; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for ServerSecurityAlertPolicyState. + */ +public enum ServerSecurityAlertPolicyState { + /** Enum value Enabled. */ + ENABLED("Enabled"), + + /** Enum value Disabled. */ + DISABLED("Disabled"); + + /** The actual serialized value for a ServerSecurityAlertPolicyState instance. */ + private String value; + + ServerSecurityAlertPolicyState(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a ServerSecurityAlertPolicyState instance. + * + * @param value the serialized value to parse. + * @return the parsed ServerSecurityAlertPolicyState object, or null if unable to parse. + */ + @JsonCreator + public static ServerSecurityAlertPolicyState fromString(String value) { + ServerSecurityAlertPolicyState[] items = ServerSecurityAlertPolicyState.values(); + for (ServerSecurityAlertPolicyState item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/implementation/LogFileInner.java b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/implementation/LogFileInner.java index 5bfb0f0ec40..62417addd6a 100644 --- a/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/implementation/LogFileInner.java +++ b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/implementation/LogFileInner.java @@ -18,12 +18,6 @@ */ @JsonFlatten public class LogFileInner extends ProxyResource { - /** - * Log file name. - */ - @JsonProperty(value = "properties.name") - private String logFileName; - /** * Size of the log file. */ @@ -54,26 +48,6 @@ public class LogFileInner extends ProxyResource { @JsonProperty(value = "properties.url") private String url; - /** - * Get the logFileName value. - * - * @return the logFileName value - */ - public String logFileName() { - return this.logFileName; - } - - /** - * Set the logFileName value. - * - * @param logFileName the logFileName value to set - * @return the LogFileInner object itself. - */ - public LogFileInner withLogFileName(String logFileName) { - this.logFileName = logFileName; - return this; - } - /** * Get the sizeInKB value. * diff --git a/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/implementation/PerformanceTierPropertiesInner.java b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/implementation/PerformanceTierPropertiesInner.java index bbbacce5da0..fd924326c8f 100644 --- a/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/implementation/PerformanceTierPropertiesInner.java +++ b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/implementation/PerformanceTierPropertiesInner.java @@ -22,30 +22,6 @@ public class PerformanceTierPropertiesInner { @JsonProperty(value = "id") private String id; - /** - * Maximum Backup retention in days for the performance tier edition. - */ - @JsonProperty(value = "maxBackupRetentionDays") - private Integer maxBackupRetentionDays; - - /** - * Minimum Backup retention in days for the performance tier edition. - */ - @JsonProperty(value = "minBackupRetentionDays") - private Integer minBackupRetentionDays; - - /** - * Max storage allowed for a server. - */ - @JsonProperty(value = "maxStorageMB") - private Integer maxStorageMB; - - /** - * Max storage allowed for a server. - */ - @JsonProperty(value = "minStorageMB") - private Integer minStorageMB; - /** * Service level objectives associated with the performance tier. */ @@ -72,86 +48,6 @@ public PerformanceTierPropertiesInner withId(String id) { return this; } - /** - * Get the maxBackupRetentionDays value. - * - * @return the maxBackupRetentionDays value - */ - public Integer maxBackupRetentionDays() { - return this.maxBackupRetentionDays; - } - - /** - * Set the maxBackupRetentionDays value. - * - * @param maxBackupRetentionDays the maxBackupRetentionDays value to set - * @return the PerformanceTierPropertiesInner object itself. - */ - public PerformanceTierPropertiesInner withMaxBackupRetentionDays(Integer maxBackupRetentionDays) { - this.maxBackupRetentionDays = maxBackupRetentionDays; - return this; - } - - /** - * Get the minBackupRetentionDays value. - * - * @return the minBackupRetentionDays value - */ - public Integer minBackupRetentionDays() { - return this.minBackupRetentionDays; - } - - /** - * Set the minBackupRetentionDays value. - * - * @param minBackupRetentionDays the minBackupRetentionDays value to set - * @return the PerformanceTierPropertiesInner object itself. - */ - public PerformanceTierPropertiesInner withMinBackupRetentionDays(Integer minBackupRetentionDays) { - this.minBackupRetentionDays = minBackupRetentionDays; - return this; - } - - /** - * Get the maxStorageMB value. - * - * @return the maxStorageMB value - */ - public Integer maxStorageMB() { - return this.maxStorageMB; - } - - /** - * Set the maxStorageMB value. - * - * @param maxStorageMB the maxStorageMB value to set - * @return the PerformanceTierPropertiesInner object itself. - */ - public PerformanceTierPropertiesInner withMaxStorageMB(Integer maxStorageMB) { - this.maxStorageMB = maxStorageMB; - return this; - } - - /** - * Get the minStorageMB value. - * - * @return the minStorageMB value - */ - public Integer minStorageMB() { - return this.minStorageMB; - } - - /** - * Set the minStorageMB value. - * - * @param minStorageMB the minStorageMB value to set - * @return the PerformanceTierPropertiesInner object itself. - */ - public PerformanceTierPropertiesInner withMinStorageMB(Integer minStorageMB) { - this.minStorageMB = minStorageMB; - return this; - } - /** * Get the serviceLevelObjectives value. * diff --git a/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/implementation/PostgreSQLManagementClientImpl.java b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/implementation/PostgreSQLManagementClientImpl.java index 88deeb8627c..5264d3183a7 100644 --- a/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/implementation/PostgreSQLManagementClientImpl.java +++ b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/implementation/PostgreSQLManagementClientImpl.java @@ -223,6 +223,19 @@ public CheckNameAvailabilitysInner checkNameAvailabilitys() { return this.checkNameAvailabilitys; } + /** + * The ServerSecurityAlertPoliciesInner object to access its operations. + */ + private ServerSecurityAlertPoliciesInner serverSecurityAlertPolicies; + + /** + * Gets the ServerSecurityAlertPoliciesInner object to access its operations. + * @return the ServerSecurityAlertPoliciesInner object. + */ + public ServerSecurityAlertPoliciesInner serverSecurityAlertPolicies() { + return this.serverSecurityAlertPolicies; + } + /** * The OperationsInner object to access its operations. */ @@ -267,7 +280,7 @@ public PostgreSQLManagementClientImpl(RestClient restClient) { } protected void initialize() { - this.apiVersion = "2017-12-01-preview"; + this.apiVersion = "2017-12-01"; this.acceptLanguage = "en-US"; this.longRunningOperationRetryTimeout = 30; this.generateClientRequestId = true; @@ -278,6 +291,7 @@ protected void initialize() { this.logFiles = new LogFilesInner(restClient().retrofit(), this); this.locationBasedPerformanceTiers = new LocationBasedPerformanceTiersInner(restClient().retrofit(), this); this.checkNameAvailabilitys = new CheckNameAvailabilitysInner(restClient().retrofit(), this); + this.serverSecurityAlertPolicies = new ServerSecurityAlertPoliciesInner(restClient().retrofit(), this); this.operations = new OperationsInner(restClient().retrofit(), this); this.azureClient = new AzureClient(this); } @@ -289,6 +303,6 @@ protected void initialize() { */ @Override public String userAgent() { - return String.format("%s (%s, %s)", super.userAgent(), "PostgreSQLManagementClient", "2017-12-01-preview"); + return String.format("%s (%s, %s)", super.userAgent(), "PostgreSQLManagementClient", "2017-12-01"); } } diff --git a/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/implementation/ServerSecurityAlertPoliciesInner.java b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/implementation/ServerSecurityAlertPoliciesInner.java new file mode 100644 index 00000000000..97a0b2e6809 --- /dev/null +++ b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/implementation/ServerSecurityAlertPoliciesInner.java @@ -0,0 +1,332 @@ +/** + * 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.postgresql.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.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 ServerSecurityAlertPolicies. + */ +public class ServerSecurityAlertPoliciesInner { + /** The Retrofit service to perform REST calls. */ + private ServerSecurityAlertPoliciesService service; + /** The service client containing this operation class. */ + private PostgreSQLManagementClientImpl client; + + /** + * Initializes an instance of ServerSecurityAlertPoliciesInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public ServerSecurityAlertPoliciesInner(Retrofit retrofit, PostgreSQLManagementClientImpl client) { + this.service = retrofit.create(ServerSecurityAlertPoliciesService.class); + this.client = client; + } + + /** + * The interface defining all the services for ServerSecurityAlertPolicies to be + * used by Retrofit to perform actually REST calls. + */ + interface ServerSecurityAlertPoliciesService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.postgresql.ServerSecurityAlertPolicies get" }) + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}") + Observable> get(@Path("resourceGroupName") String resourceGroupName, @Path("serverName") String serverName, @Path("securityAlertPolicyName") String securityAlertPolicyName, @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.postgresql.ServerSecurityAlertPolicies createOrUpdate" }) + @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}") + Observable> createOrUpdate(@Path("resourceGroupName") String resourceGroupName, @Path("serverName") String serverName, @Path("securityAlertPolicyName") String securityAlertPolicyName, @Path("subscriptionId") String subscriptionId, @Body ServerSecurityAlertPolicyInner 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.postgresql.ServerSecurityAlertPolicies beginCreateOrUpdate" }) + @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}") + Observable> beginCreateOrUpdate(@Path("resourceGroupName") String resourceGroupName, @Path("serverName") String serverName, @Path("securityAlertPolicyName") String securityAlertPolicyName, @Path("subscriptionId") String subscriptionId, @Body ServerSecurityAlertPolicyInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Get a server's security alert policy. + * + * @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 serverName The name of the server. + * @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 ServerSecurityAlertPolicyInner object if successful. + */ + public ServerSecurityAlertPolicyInner get(String resourceGroupName, String serverName) { + return getWithServiceResponseAsync(resourceGroupName, serverName).toBlocking().single().body(); + } + + /** + * Get a server's security alert policy. + * + * @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 serverName The name of the server. + * @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 serverName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(resourceGroupName, serverName), serviceCallback); + } + + /** + * Get a server's security alert policy. + * + * @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 serverName The name of the server. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ServerSecurityAlertPolicyInner object + */ + public Observable getAsync(String resourceGroupName, String serverName) { + return getWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1, ServerSecurityAlertPolicyInner>() { + @Override + public ServerSecurityAlertPolicyInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Get a server's security alert policy. + * + * @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 serverName The name of the server. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ServerSecurityAlertPolicyInner object + */ + public Observable> getWithServiceResponseAsync(String resourceGroupName, String serverName) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (serverName == null) { + throw new IllegalArgumentException("Parameter serverName 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 (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final String securityAlertPolicyName = "Default"; + return service.get(resourceGroupName, serverName, securityAlertPolicyName, this.client.subscriptionId(), this.client.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 threat detection policy. + * + * @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 serverName The name of the server. + * @param parameters The server security alert policy. + * @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 ServerSecurityAlertPolicyInner object if successful. + */ + public ServerSecurityAlertPolicyInner createOrUpdate(String resourceGroupName, String serverName, ServerSecurityAlertPolicyInner parameters) { + return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, parameters).toBlocking().last().body(); + } + + /** + * Creates or updates a threat detection policy. + * + * @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 serverName The name of the server. + * @param parameters The server security alert policy. + * @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 serverName, ServerSecurityAlertPolicyInner parameters, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, parameters), serviceCallback); + } + + /** + * Creates or updates a threat detection policy. + * + * @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 serverName The name of the server. + * @param parameters The server security alert policy. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + public Observable createOrUpdateAsync(String resourceGroupName, String serverName, ServerSecurityAlertPolicyInner parameters) { + return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, parameters).map(new Func1, ServerSecurityAlertPolicyInner>() { + @Override + public ServerSecurityAlertPolicyInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Creates or updates a threat detection policy. + * + * @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 serverName The name of the server. + * @param parameters The server security alert policy. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + public Observable> createOrUpdateWithServiceResponseAsync(String resourceGroupName, String serverName, ServerSecurityAlertPolicyInner parameters) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (serverName == null) { + throw new IllegalArgumentException("Parameter serverName 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."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(parameters); + final String securityAlertPolicyName = "Default"; + Observable> observable = service.createOrUpdate(resourceGroupName, serverName, securityAlertPolicyName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + return client.getAzureClient().getPutOrPatchResultAsync(observable, new TypeToken() { }.getType()); + } + + /** + * Creates or updates a threat detection policy. + * + * @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 serverName The name of the server. + * @param parameters The server security alert policy. + * @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 ServerSecurityAlertPolicyInner object if successful. + */ + public ServerSecurityAlertPolicyInner beginCreateOrUpdate(String resourceGroupName, String serverName, ServerSecurityAlertPolicyInner parameters) { + return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, parameters).toBlocking().single().body(); + } + + /** + * Creates or updates a threat detection policy. + * + * @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 serverName The name of the server. + * @param parameters The server security alert policy. + * @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 beginCreateOrUpdateAsync(String resourceGroupName, String serverName, ServerSecurityAlertPolicyInner parameters, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, parameters), serviceCallback); + } + + /** + * Creates or updates a threat detection policy. + * + * @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 serverName The name of the server. + * @param parameters The server security alert policy. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ServerSecurityAlertPolicyInner object + */ + public Observable beginCreateOrUpdateAsync(String resourceGroupName, String serverName, ServerSecurityAlertPolicyInner parameters) { + return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, parameters).map(new Func1, ServerSecurityAlertPolicyInner>() { + @Override + public ServerSecurityAlertPolicyInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Creates or updates a threat detection policy. + * + * @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 serverName The name of the server. + * @param parameters The server security alert policy. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ServerSecurityAlertPolicyInner object + */ + public Observable> beginCreateOrUpdateWithServiceResponseAsync(String resourceGroupName, String serverName, ServerSecurityAlertPolicyInner parameters) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (serverName == null) { + throw new IllegalArgumentException("Parameter serverName 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."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(parameters); + final String securityAlertPolicyName = "Default"; + return service.beginCreateOrUpdate(resourceGroupName, serverName, securityAlertPolicyName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = beginCreateOrUpdateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse beginCreateOrUpdateDelegate(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); + } + +} diff --git a/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/implementation/ServerSecurityAlertPolicyInner.java b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/implementation/ServerSecurityAlertPolicyInner.java new file mode 100644 index 00000000000..55ced4ed4ce --- /dev/null +++ b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/implementation/ServerSecurityAlertPolicyInner.java @@ -0,0 +1,209 @@ +/** + * 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.postgresql.implementation; + +import com.microsoft.azure.management.postgresql.ServerSecurityAlertPolicyState; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.management.postgresql.ProxyResource; + +/** + * A server security alert policy. + */ +@JsonFlatten +public class ServerSecurityAlertPolicyInner extends ProxyResource { + /** + * Specifies the state of the policy, whether it is enabled or disabled. + * Possible values include: 'Enabled', 'Disabled'. + */ + @JsonProperty(value = "properties.state", required = true) + private ServerSecurityAlertPolicyState state; + + /** + * Specifies an array of alerts that are disabled. Allowed values are: + * Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly. + */ + @JsonProperty(value = "properties.disabledAlerts") + private List disabledAlerts; + + /** + * Specifies an array of e-mail addresses to which the alert is sent. + */ + @JsonProperty(value = "properties.emailAddresses") + private List emailAddresses; + + /** + * Specifies that the alert is sent to the account administrators. + */ + @JsonProperty(value = "properties.emailAccountAdmins") + private Boolean emailAccountAdmins; + + /** + * Specifies the blob storage endpoint (e.g. + * https://MyAccount.blob.core.windows.net). This blob storage will hold + * all Threat Detection audit logs. + */ + @JsonProperty(value = "properties.storageEndpoint") + private String storageEndpoint; + + /** + * Specifies the identifier key of the Threat Detection audit storage + * account. + */ + @JsonProperty(value = "properties.storageAccountAccessKey") + private String storageAccountAccessKey; + + /** + * Specifies the number of days to keep in the Threat Detection audit logs. + */ + @JsonProperty(value = "properties.retentionDays") + private Integer retentionDays; + + /** + * Get the state value. + * + * @return the state value + */ + public ServerSecurityAlertPolicyState state() { + return this.state; + } + + /** + * Set the state value. + * + * @param state the state value to set + * @return the ServerSecurityAlertPolicyInner object itself. + */ + public ServerSecurityAlertPolicyInner withState(ServerSecurityAlertPolicyState state) { + this.state = state; + return this; + } + + /** + * Get the disabledAlerts value. + * + * @return the disabledAlerts value + */ + public List disabledAlerts() { + return this.disabledAlerts; + } + + /** + * Set the disabledAlerts value. + * + * @param disabledAlerts the disabledAlerts value to set + * @return the ServerSecurityAlertPolicyInner object itself. + */ + public ServerSecurityAlertPolicyInner withDisabledAlerts(List disabledAlerts) { + this.disabledAlerts = disabledAlerts; + return this; + } + + /** + * Get the emailAddresses value. + * + * @return the emailAddresses value + */ + public List emailAddresses() { + return this.emailAddresses; + } + + /** + * Set the emailAddresses value. + * + * @param emailAddresses the emailAddresses value to set + * @return the ServerSecurityAlertPolicyInner object itself. + */ + public ServerSecurityAlertPolicyInner withEmailAddresses(List emailAddresses) { + this.emailAddresses = emailAddresses; + return this; + } + + /** + * Get the emailAccountAdmins value. + * + * @return the emailAccountAdmins value + */ + public Boolean emailAccountAdmins() { + return this.emailAccountAdmins; + } + + /** + * Set the emailAccountAdmins value. + * + * @param emailAccountAdmins the emailAccountAdmins value to set + * @return the ServerSecurityAlertPolicyInner object itself. + */ + public ServerSecurityAlertPolicyInner withEmailAccountAdmins(Boolean emailAccountAdmins) { + this.emailAccountAdmins = emailAccountAdmins; + return this; + } + + /** + * Get the storageEndpoint value. + * + * @return the storageEndpoint value + */ + public String storageEndpoint() { + return this.storageEndpoint; + } + + /** + * Set the storageEndpoint value. + * + * @param storageEndpoint the storageEndpoint value to set + * @return the ServerSecurityAlertPolicyInner object itself. + */ + public ServerSecurityAlertPolicyInner withStorageEndpoint(String storageEndpoint) { + this.storageEndpoint = storageEndpoint; + return this; + } + + /** + * Get the storageAccountAccessKey value. + * + * @return the storageAccountAccessKey value + */ + public String storageAccountAccessKey() { + return this.storageAccountAccessKey; + } + + /** + * Set the storageAccountAccessKey value. + * + * @param storageAccountAccessKey the storageAccountAccessKey value to set + * @return the ServerSecurityAlertPolicyInner object itself. + */ + public ServerSecurityAlertPolicyInner withStorageAccountAccessKey(String storageAccountAccessKey) { + this.storageAccountAccessKey = storageAccountAccessKey; + return this; + } + + /** + * Get the retentionDays value. + * + * @return the retentionDays value + */ + public Integer retentionDays() { + return this.retentionDays; + } + + /** + * Set the retentionDays value. + * + * @param retentionDays the retentionDays value to set + * @return the ServerSecurityAlertPolicyInner object itself. + */ + public ServerSecurityAlertPolicyInner withRetentionDays(Integer retentionDays) { + this.retentionDays = retentionDays; + return this; + } + +} diff --git a/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/implementation/package-info.java b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/implementation/package-info.java index 2344e9c09b7..ca620f15ca0 100644 --- a/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/implementation/package-info.java +++ b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/implementation/package-info.java @@ -6,6 +6,6 @@ /** * This package contains the implementation classes for PostgreSQLManagementClient. - * The Microsoft Azure management API provides create, read, update, and delete functionality for Azure PostgreSQL resources including servers, databases, firewall rules, log files and configurations with new business model. + * The Microsoft Azure management API provides create, read, update, and delete functionality for Azure PostgreSQL resources including servers, databases, firewall rules, security alert policies, log files and configurations with new business model. */ package com.microsoft.azure.management.postgresql.implementation; diff --git a/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/package-info.java b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/package-info.java index 003010dccf8..48aa49d8f01 100644 --- a/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/package-info.java +++ b/azure-mgmt-postgresql/src/main/java/com/microsoft/azure/management/postgresql/package-info.java @@ -6,6 +6,6 @@ /** * This package contains the classes for PostgreSQLManagementClient. - * The Microsoft Azure management API provides create, read, update, and delete functionality for Azure PostgreSQL resources including servers, databases, firewall rules, log files and configurations with new business model. + * The Microsoft Azure management API provides create, read, update, and delete functionality for Azure PostgreSQL resources including servers, databases, firewall rules, security alert policies, log files and configurations with new business model. */ package com.microsoft.azure.management.postgresql;