"use strict";
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ManagedInstanceFailoverGroup = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
 * Manages an Azure SQL Managed Instance Failover Group.
 *
 * ## Example Usage
 *
 * > **Note:** For a more complete example, see the `./examples/sql-azure/managed_instance_failover_group` directory within the GitHub Repository.
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 *
 * const name = "mymssqlmitest";
 * const primaryName = `${name}-primary`;
 * const primaryLocation = "West Europe";
 * const failoverName = `${name}-failover`;
 * const failoverLocation = "North Europe";
 * //# Primary SQL Managed Instance
 * const primary = new azure.core.ResourceGroup("primary", {
 *     name: primaryName,
 *     location: primaryLocation,
 * });
 * const exampleZone = new azure.privatedns.Zone("example", {
 *     name: `${name}.private`,
 *     resourceGroupName: primary.name,
 * });
 * const primaryVirtualNetwork = new azure.network.VirtualNetwork("primary", {
 *     name: primaryName,
 *     location: primary.location,
 *     resourceGroupName: primary.name,
 *     addressSpaces: ["10.0.0.0/16"],
 * });
 * const primaryZoneVirtualNetworkLink = new azure.privatedns.ZoneVirtualNetworkLink("primary", {
 *     name: "primary-link",
 *     resourceGroupName: primary.name,
 *     privateDnsZoneName: exampleZone.name,
 *     virtualNetworkId: primaryVirtualNetwork.id,
 * });
 * const primarySubnet = new azure.network.Subnet("primary", {
 *     name: primaryName,
 *     resourceGroupName: primary.name,
 *     virtualNetworkName: primaryVirtualNetwork.name,
 *     addressPrefixes: ["10.0.1.0/24"],
 *     delegations: [{
 *         name: "delegation",
 *         serviceDelegation: {
 *             actions: [
 *                 "Microsoft.Network/virtualNetworks/subnets/join/action",
 *                 "Microsoft.Network/virtualNetworks/subnets/prepareNetworkPolicies/action",
 *                 "Microsoft.Network/virtualNetworks/subnets/unprepareNetworkPolicies/action",
 *             ],
 *             name: "Microsoft.Sql/managedInstances",
 *         },
 *     }],
 * });
 * const primaryNetworkSecurityGroup = new azure.network.NetworkSecurityGroup("primary", {
 *     name: primaryName,
 *     location: primary.location,
 *     resourceGroupName: primary.name,
 * });
 * const primarySubnetNetworkSecurityGroupAssociation = new azure.network.SubnetNetworkSecurityGroupAssociation("primary", {
 *     subnetId: primarySubnet.id,
 *     networkSecurityGroupId: primaryNetworkSecurityGroup.id,
 * });
 * const primaryRouteTable = new azure.network.RouteTable("primary", {
 *     name: primaryName,
 *     location: primary.location,
 *     resourceGroupName: primary.name,
 * });
 * const primarySubnetRouteTableAssociation = new azure.network.SubnetRouteTableAssociation("primary", {
 *     subnetId: primarySubnet.id,
 *     routeTableId: primaryRouteTable.id,
 * });
 * const primaryManagedInstance = new azure.mssql.ManagedInstance("primary", {
 *     name: primaryName,
 *     resourceGroupName: primary.name,
 *     location: primary.location,
 *     administratorLogin: "mradministrator",
 *     administratorLoginPassword: "thisIsDog11",
 *     licenseType: "BasePrice",
 *     subnetId: primarySubnet.id,
 *     skuName: "GP_Gen5",
 *     vcores: 4,
 *     storageSizeInGb: 32,
 * }, {
 *     dependsOn: [
 *         primarySubnetNetworkSecurityGroupAssociation,
 *         primarySubnetRouteTableAssociation,
 *     ],
 * });
 * //# Secondary (Fail-over) SQL Managed Instance
 * const failover = new azure.core.ResourceGroup("failover", {
 *     name: failoverName,
 *     location: failoverLocation,
 * });
 * const failoverVirtualNetwork = new azure.network.VirtualNetwork("failover", {
 *     name: failoverName,
 *     location: failover.location,
 *     resourceGroupName: failover.name,
 *     addressSpaces: ["10.1.0.0/16"],
 * });
 * const failoverZoneVirtualNetworkLink = new azure.privatedns.ZoneVirtualNetworkLink("failover", {
 *     name: "failover-link",
 *     resourceGroupName: exampleZone.resourceGroupName,
 *     privateDnsZoneName: exampleZone.name,
 *     virtualNetworkId: failoverVirtualNetwork.id,
 * });
 * const failoverSubnet = new azure.network.Subnet("failover", {
 *     name: "ManagedInstance",
 *     resourceGroupName: failover.name,
 *     virtualNetworkName: failoverVirtualNetwork.name,
 *     addressPrefixes: ["10.1.1.0/24"],
 *     delegations: [{
 *         name: "delegation",
 *         serviceDelegation: {
 *             actions: [
 *                 "Microsoft.Network/virtualNetworks/subnets/join/action",
 *                 "Microsoft.Network/virtualNetworks/subnets/prepareNetworkPolicies/action",
 *                 "Microsoft.Network/virtualNetworks/subnets/unprepareNetworkPolicies/action",
 *             ],
 *             name: "Microsoft.Sql/managedInstances",
 *         },
 *     }],
 * });
 * const failoverNetworkSecurityGroup = new azure.network.NetworkSecurityGroup("failover", {
 *     name: failoverName,
 *     location: failover.location,
 *     resourceGroupName: failover.name,
 * });
 * const failoverSubnetNetworkSecurityGroupAssociation = new azure.network.SubnetNetworkSecurityGroupAssociation("failover", {
 *     subnetId: failoverSubnet.id,
 *     networkSecurityGroupId: failoverNetworkSecurityGroup.id,
 * });
 * const failoverRouteTable = new azure.network.RouteTable("failover", {
 *     name: failoverName,
 *     location: failover.location,
 *     resourceGroupName: failover.name,
 * });
 * const failoverSubnetRouteTableAssociation = new azure.network.SubnetRouteTableAssociation("failover", {
 *     subnetId: failoverSubnet.id,
 *     routeTableId: failoverRouteTable.id,
 * });
 * const failoverManagedInstance = new azure.mssql.ManagedInstance("failover", {
 *     name: failoverName,
 *     resourceGroupName: failover.name,
 *     location: failover.location,
 *     administratorLogin: "mradministrator",
 *     administratorLoginPassword: "thisIsDog11",
 *     licenseType: "BasePrice",
 *     subnetId: failoverSubnet.id,
 *     skuName: "GP_Gen5",
 *     vcores: 4,
 *     storageSizeInGb: 32,
 *     dnsZonePartnerId: primaryManagedInstance.id,
 * }, {
 *     dependsOn: [
 *         failoverSubnetNetworkSecurityGroupAssociation,
 *         failoverSubnetRouteTableAssociation,
 *     ],
 * });
 * const example = new azure.mssql.ManagedInstanceFailoverGroup("example", {
 *     name: "example-failover-group",
 *     location: primaryManagedInstance.location,
 *     managedInstanceId: primaryManagedInstance.id,
 *     partnerManagedInstanceId: failoverManagedInstance.id,
 *     secondaryType: "Geo",
 *     readWriteEndpointFailoverPolicy: {
 *         mode: "Automatic",
 *         graceMinutes: 60,
 *     },
 * }, {
 *     dependsOn: [
 *         primaryZoneVirtualNetworkLink,
 *         failoverZoneVirtualNetworkLink,
 *     ],
 * });
 * const primaryToFailover = new azure.network.VirtualNetworkPeering("primary_to_failover", {
 *     name: "primary-to-failover",
 *     remoteVirtualNetworkId: failoverVirtualNetwork.id,
 *     resourceGroupName: primary.name,
 *     virtualNetworkName: primaryVirtualNetwork.name,
 * });
 * const _default = new azure.network.Subnet("default", {
 *     name: "default",
 *     resourceGroupName: failover.name,
 *     virtualNetworkName: failoverVirtualNetwork.name,
 *     addressPrefixes: ["10.1.0.0/24"],
 * });
 * const failoverToPrimary = new azure.network.VirtualNetworkPeering("failover_to_primary", {
 *     name: "failover-to-primary",
 *     remoteVirtualNetworkId: primaryVirtualNetwork.id,
 *     resourceGroupName: failover.name,
 *     virtualNetworkName: failoverVirtualNetwork.name,
 * });
 * ```
 *
 * > **Note:** There are many prerequisites that must be in place before creating the failover group. To see them all, refer to [Configure a failover group for Azure SQL Managed Instance](https://learn.microsoft.com/en-us/azure/azure-sql/managed-instance/failover-group-configure-sql-mi).
 *
 * ## API Providers
 *
 * <!-- This section is generated, changes will be overwritten -->
 * This resource uses the following Azure API Providers:
 *
 * * `Microsoft.Sql` - 2023-08-01-preview
 *
 * ## Import
 *
 * SQL Instance Failover Groups can be imported using the `resource id`, e.g.
 *
 * ```sh
 * $ pulumi import azure:mssql/managedInstanceFailoverGroup:ManagedInstanceFailoverGroup example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Sql/locations/Location/instanceFailoverGroups/failoverGroup1
 * ```
 */
class ManagedInstanceFailoverGroup extends pulumi.CustomResource {
    /**
     * Get an existing ManagedInstanceFailoverGroup 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 Any extra arguments used during the lookup.
     * @param opts Optional settings to control the behavior of the CustomResource.
     */
    static get(name, id, state, opts) {
        return new ManagedInstanceFailoverGroup(name, state, { ...opts, id: id });
    }
    /** @internal */
    static __pulumiType = 'azure:mssql/managedInstanceFailoverGroup:ManagedInstanceFailoverGroup';
    /**
     * Returns true if the given object is an instance of ManagedInstanceFailoverGroup.  This is designed to work even
     * when multiple copies of the Pulumi SDK have been loaded into the same process.
     */
    static isInstance(obj) {
        if (obj === undefined || obj === null) {
            return false;
        }
        return obj['__pulumiType'] === ManagedInstanceFailoverGroup.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["location"] = state?.location;
            resourceInputs["managedInstanceId"] = state?.managedInstanceId;
            resourceInputs["name"] = state?.name;
            resourceInputs["partnerManagedInstanceId"] = state?.partnerManagedInstanceId;
            resourceInputs["partnerRegions"] = state?.partnerRegions;
            resourceInputs["readWriteEndpointFailoverPolicy"] = state?.readWriteEndpointFailoverPolicy;
            resourceInputs["readonlyEndpointFailoverPolicyEnabled"] = state?.readonlyEndpointFailoverPolicyEnabled;
            resourceInputs["role"] = state?.role;
            resourceInputs["secondaryType"] = state?.secondaryType;
        }
        else {
            const args = argsOrState;
            if (args?.managedInstanceId === undefined && !opts.urn) {
                throw new Error("Missing required property 'managedInstanceId'");
            }
            if (args?.partnerManagedInstanceId === undefined && !opts.urn) {
                throw new Error("Missing required property 'partnerManagedInstanceId'");
            }
            if (args?.readWriteEndpointFailoverPolicy === undefined && !opts.urn) {
                throw new Error("Missing required property 'readWriteEndpointFailoverPolicy'");
            }
            resourceInputs["location"] = args?.location;
            resourceInputs["managedInstanceId"] = args?.managedInstanceId;
            resourceInputs["name"] = args?.name;
            resourceInputs["partnerManagedInstanceId"] = args?.partnerManagedInstanceId;
            resourceInputs["readWriteEndpointFailoverPolicy"] = args?.readWriteEndpointFailoverPolicy;
            resourceInputs["readonlyEndpointFailoverPolicyEnabled"] = args?.readonlyEndpointFailoverPolicyEnabled;
            resourceInputs["secondaryType"] = args?.secondaryType;
            resourceInputs["partnerRegions"] = undefined /*out*/;
            resourceInputs["role"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        const aliasOpts = { aliases: [{ type: "azure:sql/managedInstanceFailoverGroup:ManagedInstanceFailoverGroup" }] };
        opts = pulumi.mergeOptions(opts, aliasOpts);
        super(ManagedInstanceFailoverGroup.__pulumiType, name, resourceInputs, opts);
    }
}
exports.ManagedInstanceFailoverGroup = ManagedInstanceFailoverGroup;
//# sourceMappingURL=managedInstanceFailoverGroup.js.map