// *** WARNING: this file was generated by pulumi-java-gen. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

package com.pulumi.azure.postgresql;

import com.pulumi.azure.Utilities;
import com.pulumi.azure.postgresql.FlexibleServerArgs;
import com.pulumi.azure.postgresql.inputs.FlexibleServerState;
import com.pulumi.azure.postgresql.outputs.FlexibleServerAuthentication;
import com.pulumi.azure.postgresql.outputs.FlexibleServerCustomerManagedKey;
import com.pulumi.azure.postgresql.outputs.FlexibleServerHighAvailability;
import com.pulumi.azure.postgresql.outputs.FlexibleServerIdentity;
import com.pulumi.azure.postgresql.outputs.FlexibleServerMaintenanceWindow;
import com.pulumi.core.Output;
import com.pulumi.core.annotations.Export;
import com.pulumi.core.annotations.ResourceType;
import com.pulumi.core.internal.Codegen;
import java.lang.Boolean;
import java.lang.Integer;
import java.lang.String;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Nullable;

/**
 * Manages a PostgreSQL Flexible Server.
 * 
 * ## Example Usage
 * ```java
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.azure.core.ResourceGroup;
 * import com.pulumi.azure.core.ResourceGroupArgs;
 * import com.pulumi.azure.network.VirtualNetwork;
 * import com.pulumi.azure.network.VirtualNetworkArgs;
 * import com.pulumi.azure.network.Subnet;
 * import com.pulumi.azure.network.SubnetArgs;
 * import com.pulumi.azure.network.inputs.SubnetDelegationArgs;
 * import com.pulumi.azure.network.inputs.SubnetDelegationServiceDelegationArgs;
 * import com.pulumi.azure.privatedns.Zone;
 * import com.pulumi.azure.privatedns.ZoneArgs;
 * import com.pulumi.azure.privatedns.ZoneVirtualNetworkLink;
 * import com.pulumi.azure.privatedns.ZoneVirtualNetworkLinkArgs;
 * import com.pulumi.azure.postgresql.FlexibleServer;
 * import com.pulumi.azure.postgresql.FlexibleServerArgs;
 * import com.pulumi.resources.CustomResourceOptions;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * 
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 * 
 *     public static void stack(Context ctx) {
 *         var exampleResourceGroup = new ResourceGroup(&#34;exampleResourceGroup&#34;, ResourceGroupArgs.builder()        
 *             .location(&#34;West Europe&#34;)
 *             .build());
 * 
 *         var exampleVirtualNetwork = new VirtualNetwork(&#34;exampleVirtualNetwork&#34;, VirtualNetworkArgs.builder()        
 *             .location(exampleResourceGroup.location())
 *             .resourceGroupName(exampleResourceGroup.name())
 *             .addressSpaces(&#34;10.0.0.0/16&#34;)
 *             .build());
 * 
 *         var exampleSubnet = new Subnet(&#34;exampleSubnet&#34;, SubnetArgs.builder()        
 *             .resourceGroupName(exampleResourceGroup.name())
 *             .virtualNetworkName(exampleVirtualNetwork.name())
 *             .addressPrefixes(&#34;10.0.2.0/24&#34;)
 *             .serviceEndpoints(&#34;Microsoft.Storage&#34;)
 *             .delegations(SubnetDelegationArgs.builder()
 *                 .name(&#34;fs&#34;)
 *                 .serviceDelegation(SubnetDelegationServiceDelegationArgs.builder()
 *                     .name(&#34;Microsoft.DBforPostgreSQL/flexibleServers&#34;)
 *                     .actions(&#34;Microsoft.Network/virtualNetworks/subnets/join/action&#34;)
 *                     .build())
 *                 .build())
 *             .build());
 * 
 *         var exampleZone = new Zone(&#34;exampleZone&#34;, ZoneArgs.builder()        
 *             .resourceGroupName(exampleResourceGroup.name())
 *             .build());
 * 
 *         var exampleZoneVirtualNetworkLink = new ZoneVirtualNetworkLink(&#34;exampleZoneVirtualNetworkLink&#34;, ZoneVirtualNetworkLinkArgs.builder()        
 *             .privateDnsZoneName(exampleZone.name())
 *             .virtualNetworkId(exampleVirtualNetwork.id())
 *             .resourceGroupName(exampleResourceGroup.name())
 *             .build());
 * 
 *         var exampleFlexibleServer = new FlexibleServer(&#34;exampleFlexibleServer&#34;, FlexibleServerArgs.builder()        
 *             .resourceGroupName(exampleResourceGroup.name())
 *             .location(exampleResourceGroup.location())
 *             .version(&#34;12&#34;)
 *             .delegatedSubnetId(exampleSubnet.id())
 *             .privateDnsZoneId(exampleZone.id())
 *             .administratorLogin(&#34;psqladmin&#34;)
 *             .administratorPassword(&#34;H@Sh1CoR3!&#34;)
 *             .zone(&#34;1&#34;)
 *             .storageMb(32768)
 *             .skuName(&#34;GP_Standard_D4s_v3&#34;)
 *             .build(), CustomResourceOptions.builder()
 *                 .dependsOn(exampleZoneVirtualNetworkLink)
 *                 .build());
 * 
 *     }
 * }
 * ```
 * 
 * ## Import
 * 
 * PostgreSQL Flexible Servers can be imported using the `resource id`, e.g.
 * 
 * ```sh
 *  $ pulumi import azure:postgresql/flexibleServer:FlexibleServer example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.DBforPostgreSQL/flexibleServers/server1
 * ```
 * 
 */
@ResourceType(type="azure:postgresql/flexibleServer:FlexibleServer")
public class FlexibleServer extends com.pulumi.resources.CustomResource {
    /**
     * The Administrator login for the PostgreSQL Flexible Server. Required when `create_mode` is `Default` and `authentication.password_auth_enabled` is `true`.
     * 
     * &gt; **Note:** Once `administrator_login` is specified, changing this forces a new PostgreSQL Flexible Server to be created.
     * 
     * &gt; **Note:** To create with `administrator_login` specified or update with it first specified , `authentication.password_auth_enabled` must be set to `true`.
     * 
     */
    @Export(name="administratorLogin", refs={String.class}, tree="[0]")
    private Output<String> administratorLogin;

    /**
     * @return The Administrator login for the PostgreSQL Flexible Server. Required when `create_mode` is `Default` and `authentication.password_auth_enabled` is `true`.
     * 
     * &gt; **Note:** Once `administrator_login` is specified, changing this forces a new PostgreSQL Flexible Server to be created.
     * 
     * &gt; **Note:** To create with `administrator_login` specified or update with it first specified , `authentication.password_auth_enabled` must be set to `true`.
     * 
     */
    public Output<String> administratorLogin() {
        return this.administratorLogin;
    }
    /**
     * The Password associated with the `administrator_login` for the PostgreSQL Flexible Server. Required when `create_mode` is `Default` and `authentication.password_auth_enabled` is `true`.
     * 
     */
    @Export(name="administratorPassword", refs={String.class}, tree="[0]")
    private Output</* @Nullable */ String> administratorPassword;

    /**
     * @return The Password associated with the `administrator_login` for the PostgreSQL Flexible Server. Required when `create_mode` is `Default` and `authentication.password_auth_enabled` is `true`.
     * 
     */
    public Output<Optional<String>> administratorPassword() {
        return Codegen.optional(this.administratorPassword);
    }
    /**
     * An `authentication` block as defined below.
     * 
     */
    @Export(name="authentication", refs={FlexibleServerAuthentication.class}, tree="[0]")
    private Output<FlexibleServerAuthentication> authentication;

    /**
     * @return An `authentication` block as defined below.
     * 
     */
    public Output<FlexibleServerAuthentication> authentication() {
        return this.authentication;
    }
    /**
     * The backup retention days for the PostgreSQL Flexible Server. Possible values are between `7` and `35` days.
     * 
     */
    @Export(name="backupRetentionDays", refs={Integer.class}, tree="[0]")
    private Output<Integer> backupRetentionDays;

    /**
     * @return The backup retention days for the PostgreSQL Flexible Server. Possible values are between `7` and `35` days.
     * 
     */
    public Output<Integer> backupRetentionDays() {
        return this.backupRetentionDays;
    }
    /**
     * The creation mode which can be used to restore or replicate existing servers. Possible values are `Default`, `PointInTimeRestore`, `Replica` and `Update`. Changing this forces a new PostgreSQL Flexible Server to be created.
     * 
     * &gt; **Note:** While creating the resource, `create_mode` cannot be set to `Update`.
     * 
     */
    @Export(name="createMode", refs={String.class}, tree="[0]")
    private Output</* @Nullable */ String> createMode;

    /**
     * @return The creation mode which can be used to restore or replicate existing servers. Possible values are `Default`, `PointInTimeRestore`, `Replica` and `Update`. Changing this forces a new PostgreSQL Flexible Server to be created.
     * 
     * &gt; **Note:** While creating the resource, `create_mode` cannot be set to `Update`.
     * 
     */
    public Output<Optional<String>> createMode() {
        return Codegen.optional(this.createMode);
    }
    /**
     * A `customer_managed_key` block as defined below. Changing this forces a new resource to be created.
     * 
     */
    @Export(name="customerManagedKey", refs={FlexibleServerCustomerManagedKey.class}, tree="[0]")
    private Output</* @Nullable */ FlexibleServerCustomerManagedKey> customerManagedKey;

    /**
     * @return A `customer_managed_key` block as defined below. Changing this forces a new resource to be created.
     * 
     */
    public Output<Optional<FlexibleServerCustomerManagedKey>> customerManagedKey() {
        return Codegen.optional(this.customerManagedKey);
    }
    /**
     * The ID of the virtual network subnet to create the PostgreSQL Flexible Server. The provided subnet should not have any other resource deployed in it and this subnet will be delegated to the PostgreSQL Flexible Server, if not already delegated. Changing this forces a new PostgreSQL Flexible Server to be created.
     * 
     */
    @Export(name="delegatedSubnetId", refs={String.class}, tree="[0]")
    private Output</* @Nullable */ String> delegatedSubnetId;

    /**
     * @return The ID of the virtual network subnet to create the PostgreSQL Flexible Server. The provided subnet should not have any other resource deployed in it and this subnet will be delegated to the PostgreSQL Flexible Server, if not already delegated. Changing this forces a new PostgreSQL Flexible Server to be created.
     * 
     */
    public Output<Optional<String>> delegatedSubnetId() {
        return Codegen.optional(this.delegatedSubnetId);
    }
    /**
     * The FQDN of the PostgreSQL Flexible Server.
     * 
     */
    @Export(name="fqdn", refs={String.class}, tree="[0]")
    private Output<String> fqdn;

    /**
     * @return The FQDN of the PostgreSQL Flexible Server.
     * 
     */
    public Output<String> fqdn() {
        return this.fqdn;
    }
    /**
     * Is Geo-Redundant backup enabled on the PostgreSQL Flexible Server. Defaults to `false`. Changing this forces a new PostgreSQL Flexible Server to be created.
     * 
     */
    @Export(name="geoRedundantBackupEnabled", refs={Boolean.class}, tree="[0]")
    private Output</* @Nullable */ Boolean> geoRedundantBackupEnabled;

    /**
     * @return Is Geo-Redundant backup enabled on the PostgreSQL Flexible Server. Defaults to `false`. Changing this forces a new PostgreSQL Flexible Server to be created.
     * 
     */
    public Output<Optional<Boolean>> geoRedundantBackupEnabled() {
        return Codegen.optional(this.geoRedundantBackupEnabled);
    }
    /**
     * A `high_availability` block as defined below.
     * 
     */
    @Export(name="highAvailability", refs={FlexibleServerHighAvailability.class}, tree="[0]")
    private Output</* @Nullable */ FlexibleServerHighAvailability> highAvailability;

    /**
     * @return A `high_availability` block as defined below.
     * 
     */
    public Output<Optional<FlexibleServerHighAvailability>> highAvailability() {
        return Codegen.optional(this.highAvailability);
    }
    /**
     * An `identity` block as defined below.
     * 
     */
    @Export(name="identity", refs={FlexibleServerIdentity.class}, tree="[0]")
    private Output</* @Nullable */ FlexibleServerIdentity> identity;

    /**
     * @return An `identity` block as defined below.
     * 
     */
    public Output<Optional<FlexibleServerIdentity>> identity() {
        return Codegen.optional(this.identity);
    }
    /**
     * The Azure Region where the PostgreSQL Flexible Server should exist. Changing this forces a new PostgreSQL Flexible Server to be created.
     * 
     */
    @Export(name="location", refs={String.class}, tree="[0]")
    private Output<String> location;

    /**
     * @return The Azure Region where the PostgreSQL Flexible Server should exist. Changing this forces a new PostgreSQL Flexible Server to be created.
     * 
     */
    public Output<String> location() {
        return this.location;
    }
    /**
     * A `maintenance_window` block as defined below.
     * 
     */
    @Export(name="maintenanceWindow", refs={FlexibleServerMaintenanceWindow.class}, tree="[0]")
    private Output</* @Nullable */ FlexibleServerMaintenanceWindow> maintenanceWindow;

    /**
     * @return A `maintenance_window` block as defined below.
     * 
     */
    public Output<Optional<FlexibleServerMaintenanceWindow>> maintenanceWindow() {
        return Codegen.optional(this.maintenanceWindow);
    }
    /**
     * The name which should be used for this PostgreSQL Flexible Server. Changing this forces a new PostgreSQL Flexible Server to be created.
     * 
     * &gt; **Note** This must be unique across the entire Azure service, not just within the resource group.
     * 
     */
    @Export(name="name", refs={String.class}, tree="[0]")
    private Output<String> name;

    /**
     * @return The name which should be used for this PostgreSQL Flexible Server. Changing this forces a new PostgreSQL Flexible Server to be created.
     * 
     * &gt; **Note** This must be unique across the entire Azure service, not just within the resource group.
     * 
     */
    public Output<String> name() {
        return this.name;
    }
    /**
     * The point in time to restore from `source_server_id` when `create_mode` is `PointInTimeRestore`. Changing this forces a new PostgreSQL Flexible Server to be created.
     * 
     */
    @Export(name="pointInTimeRestoreTimeInUtc", refs={String.class}, tree="[0]")
    private Output</* @Nullable */ String> pointInTimeRestoreTimeInUtc;

    /**
     * @return The point in time to restore from `source_server_id` when `create_mode` is `PointInTimeRestore`. Changing this forces a new PostgreSQL Flexible Server to be created.
     * 
     */
    public Output<Optional<String>> pointInTimeRestoreTimeInUtc() {
        return Codegen.optional(this.pointInTimeRestoreTimeInUtc);
    }
    /**
     * The ID of the private DNS zone to create the PostgreSQL Flexible Server. Changing this forces a new PostgreSQL Flexible Server to be created.
     * 
     * &gt; **NOTE:** There will be a breaking change from upstream service at 15th July 2021, the `private_dns_zone_id` will be required when setting a `delegated_subnet_id`. For existing flexible servers who don&#39;t want to be recreated, you need to provide the `private_dns_zone_id` to the service team to manually migrate to the specified private DNS zone. The `azure.privatedns.Zone` should end with suffix `.postgres.database.azure.com`.
     * 
     */
    @Export(name="privateDnsZoneId", refs={String.class}, tree="[0]")
    private Output<String> privateDnsZoneId;

    /**
     * @return The ID of the private DNS zone to create the PostgreSQL Flexible Server. Changing this forces a new PostgreSQL Flexible Server to be created.
     * 
     * &gt; **NOTE:** There will be a breaking change from upstream service at 15th July 2021, the `private_dns_zone_id` will be required when setting a `delegated_subnet_id`. For existing flexible servers who don&#39;t want to be recreated, you need to provide the `private_dns_zone_id` to the service team to manually migrate to the specified private DNS zone. The `azure.privatedns.Zone` should end with suffix `.postgres.database.azure.com`.
     * 
     */
    public Output<String> privateDnsZoneId() {
        return this.privateDnsZoneId;
    }
    /**
     * Is public network access enabled?
     * 
     */
    @Export(name="publicNetworkAccessEnabled", refs={Boolean.class}, tree="[0]")
    private Output<Boolean> publicNetworkAccessEnabled;

    /**
     * @return Is public network access enabled?
     * 
     */
    public Output<Boolean> publicNetworkAccessEnabled() {
        return this.publicNetworkAccessEnabled;
    }
    /**
     * The replication role for the PostgreSQL Flexible Server. Possible value is `None`.
     * 
     * &gt; **NOTE:** The `replication_role` cannot be set while creating and only can be updated to `None` for replica server.
     * 
     */
    @Export(name="replicationRole", refs={String.class}, tree="[0]")
    private Output</* @Nullable */ String> replicationRole;

    /**
     * @return The replication role for the PostgreSQL Flexible Server. Possible value is `None`.
     * 
     * &gt; **NOTE:** The `replication_role` cannot be set while creating and only can be updated to `None` for replica server.
     * 
     */
    public Output<Optional<String>> replicationRole() {
        return Codegen.optional(this.replicationRole);
    }
    /**
     * The name of the Resource Group where the PostgreSQL Flexible Server should exist. Changing this forces a new PostgreSQL Flexible Server to be created.
     * 
     */
    @Export(name="resourceGroupName", refs={String.class}, tree="[0]")
    private Output<String> resourceGroupName;

    /**
     * @return The name of the Resource Group where the PostgreSQL Flexible Server should exist. Changing this forces a new PostgreSQL Flexible Server to be created.
     * 
     */
    public Output<String> resourceGroupName() {
        return this.resourceGroupName;
    }
    /**
     * The SKU Name for the PostgreSQL Flexible Server. The name of the SKU, follows the `tier` + `name` pattern (e.g. `B_Standard_B1ms`, `GP_Standard_D2s_v3`, `MO_Standard_E4s_v3`).
     * 
     */
    @Export(name="skuName", refs={String.class}, tree="[0]")
    private Output<String> skuName;

    /**
     * @return The SKU Name for the PostgreSQL Flexible Server. The name of the SKU, follows the `tier` + `name` pattern (e.g. `B_Standard_B1ms`, `GP_Standard_D2s_v3`, `MO_Standard_E4s_v3`).
     * 
     */
    public Output<String> skuName() {
        return this.skuName;
    }
    /**
     * The resource ID of the source PostgreSQL Flexible Server to be restored. Required when `create_mode` is `PointInTimeRestore` or `Replica`. Changing this forces a new PostgreSQL Flexible Server to be created.
     * 
     */
    @Export(name="sourceServerId", refs={String.class}, tree="[0]")
    private Output</* @Nullable */ String> sourceServerId;

    /**
     * @return The resource ID of the source PostgreSQL Flexible Server to be restored. Required when `create_mode` is `PointInTimeRestore` or `Replica`. Changing this forces a new PostgreSQL Flexible Server to be created.
     * 
     */
    public Output<Optional<String>> sourceServerId() {
        return Codegen.optional(this.sourceServerId);
    }
    /**
     * The max storage allowed for the PostgreSQL Flexible Server. Possible values are `32768`, `65536`, `131072`, `262144`, `524288`, `1048576`, `2097152`, `4194304`, `8388608`, `16777216` and `33553408`.
     * 
     */
    @Export(name="storageMb", refs={Integer.class}, tree="[0]")
    private Output<Integer> storageMb;

    /**
     * @return The max storage allowed for the PostgreSQL Flexible Server. Possible values are `32768`, `65536`, `131072`, `262144`, `524288`, `1048576`, `2097152`, `4194304`, `8388608`, `16777216` and `33553408`.
     * 
     */
    public Output<Integer> storageMb() {
        return this.storageMb;
    }
    /**
     * A mapping of tags which should be assigned to the PostgreSQL Flexible Server.
     * 
     */
    @Export(name="tags", refs={Map.class,String.class}, tree="[0,1,1]")
    private Output</* @Nullable */ Map<String,String>> tags;

    /**
     * @return A mapping of tags which should be assigned to the PostgreSQL Flexible Server.
     * 
     */
    public Output<Optional<Map<String,String>>> tags() {
        return Codegen.optional(this.tags);
    }
    /**
     * The version of PostgreSQL Flexible Server to use. Possible values are `11`,`12`, `13`, `14` and `15`. Required when `create_mode` is `Default`. Changing this forces a new PostgreSQL Flexible Server to be created.
     * 
     * &gt; **Note:** When `create_mode` is `Update`, upgrading version wouldn&#39;t force a new resource to be created.
     * 
     */
    @Export(name="version", refs={String.class}, tree="[0]")
    private Output<String> version;

    /**
     * @return The version of PostgreSQL Flexible Server to use. Possible values are `11`,`12`, `13`, `14` and `15`. Required when `create_mode` is `Default`. Changing this forces a new PostgreSQL Flexible Server to be created.
     * 
     * &gt; **Note:** When `create_mode` is `Update`, upgrading version wouldn&#39;t force a new resource to be created.
     * 
     */
    public Output<String> version() {
        return this.version;
    }
    @Export(name="zone", refs={String.class}, tree="[0]")
    private Output</* @Nullable */ String> zone;

    public Output<Optional<String>> zone() {
        return Codegen.optional(this.zone);
    }

    /**
     *
     * @param name The _unique_ name of the resulting resource.
     */
    public FlexibleServer(String name) {
        this(name, FlexibleServerArgs.Empty);
    }
    /**
     *
     * @param name The _unique_ name of the resulting resource.
     * @param args The arguments to use to populate this resource's properties.
     */
    public FlexibleServer(String name, FlexibleServerArgs args) {
        this(name, args, null);
    }
    /**
     *
     * @param name The _unique_ name of the resulting resource.
     * @param args The arguments to use to populate this resource's properties.
     * @param options A bag of options that control this resource's behavior.
     */
    public FlexibleServer(String name, FlexibleServerArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        super("azure:postgresql/flexibleServer:FlexibleServer", name, args == null ? FlexibleServerArgs.Empty : args, makeResourceOptions(options, Codegen.empty()));
    }

    private FlexibleServer(String name, Output<String> id, @Nullable FlexibleServerState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        super("azure:postgresql/flexibleServer:FlexibleServer", name, state, makeResourceOptions(options, id));
    }

    private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output<String> id) {
        var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder()
            .version(Utilities.getVersion())
            .additionalSecretOutputs(List.of(
                "administratorPassword"
            ))
            .build();
        return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id);
    }

    /**
     * Get an existing Host resource's state with the given name, ID, and optional extra
     * properties used to qualify the lookup.
     *
     * @param name The _unique_ name of the resulting resource.
     * @param id The _unique_ provider ID of the resource to lookup.
     * @param state
     * @param options Optional settings to control the behavior of the CustomResource.
     */
    public static FlexibleServer get(String name, Output<String> id, @Nullable FlexibleServerState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        return new FlexibleServer(name, id, state, options);
    }
}
