"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.ServerExtendedAuditingPolicy = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
 * Manages a MS SQL Server Extended Auditing Policy.
 *
 * ## Example Usage
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 *
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "example-resources",
 *     location: "West Europe",
 * });
 * const exampleServer = new azure.mssql.Server("example", {
 *     name: "example-sqlserver",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     version: "12.0",
 *     administratorLogin: "missadministrator",
 *     administratorLoginPassword: "AdminPassword123!",
 * });
 * const exampleAccount = new azure.storage.Account("example", {
 *     name: "examplesa",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     accountTier: "Standard",
 *     accountReplicationType: "LRS",
 * });
 * const exampleServerExtendedAuditingPolicy = new azure.mssql.ServerExtendedAuditingPolicy("example", {
 *     serverId: exampleServer.id,
 *     storageEndpoint: exampleAccount.primaryBlobEndpoint,
 *     storageAccountAccessKey: exampleAccount.primaryAccessKey,
 *     storageAccountAccessKeyIsSecondary: false,
 *     retentionInDays: 6,
 * });
 * ```
 *
 * ### With Storage Account Behind VNet And Firewall
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * import * as azurerm from "@pulumi/azurerm";
 *
 * const primary = azure.core.getSubscription({});
 * const example = azure.core.getClientConfig({});
 * const exampleResourceGroup = new azure.core.ResourceGroup("example", {
 *     name: "example",
 *     location: "West Europe",
 * });
 * const exampleVirtualNetwork = new azure.network.VirtualNetwork("example", {
 *     name: "virtnetname-1",
 *     addressSpaces: ["10.0.0.0/16"],
 *     location: exampleResourceGroup.location,
 *     resourceGroupName: exampleResourceGroup.name,
 * });
 * const exampleSubnet = new azure.network.Subnet("example", {
 *     name: "subnetname-1",
 *     resourceGroupName: exampleResourceGroup.name,
 *     virtualNetworkName: exampleVirtualNetwork.name,
 *     addressPrefixes: ["10.0.2.0/24"],
 *     serviceEndpoints: [
 *         "Microsoft.Sql",
 *         "Microsoft.Storage",
 *     ],
 *     enforcePrivateLinkEndpointNetworkPolicies: true,
 * });
 * const exampleServer = new azure.mssql.Server("example", {
 *     name: "example-sqlserver",
 *     resourceGroupName: exampleResourceGroup.name,
 *     location: exampleResourceGroup.location,
 *     version: "12.0",
 *     administratorLogin: "missadministrator",
 *     administratorLoginPassword: "AdminPassword123!",
 *     minimumTlsVersion: "1.2",
 *     identity: {
 *         type: "SystemAssigned",
 *     },
 * });
 * const exampleAssignment = new azure.authorization.Assignment("example", {
 *     scope: primary.then(primary => primary.id),
 *     roleDefinitionName: "Storage Blob Data Contributor",
 *     principalId: exampleServer.identity.apply(identity => identity?.principalId),
 * });
 * const sqlvnetrule = new azurerm.index.SqlVirtualNetworkRule("sqlvnetrule", {
 *     name: "sql-vnet-rule",
 *     resourceGroupName: exampleResourceGroup.name,
 *     serverName: exampleServer.name,
 *     subnetId: exampleSubnet.id,
 * });
 * const exampleSqlFirewallRule = new azurerm.index.SqlFirewallRule("example", {
 *     name: "FirewallRule1",
 *     resourceGroupName: exampleResourceGroup.name,
 *     serverName: exampleServer.name,
 *     startIpAddress: "0.0.0.0",
 *     endIpAddress: "0.0.0.0",
 * });
 * const exampleAccount = new azure.storage.Account("example", {
 *     name: "examplesa",
 *     resourceGroupName: exampleResourceGroup.name,
 *     location: exampleResourceGroup.location,
 *     accountTier: "Standard",
 *     accountReplicationType: "LRS",
 *     accountKind: "StorageV2",
 *     allowNestedItemsToBePublic: false,
 *     networkRules: {
 *         defaultAction: "Deny",
 *         ipRules: ["127.0.0.1"],
 *         virtualNetworkSubnetIds: [exampleSubnet.id],
 *         bypasses: ["AzureServices"],
 *     },
 *     identity: {
 *         type: "SystemAssigned",
 *     },
 * });
 * const exampleServerExtendedAuditingPolicy = new azure.mssql.ServerExtendedAuditingPolicy("example", {
 *     storageEndpoint: exampleAccount.primaryBlobEndpoint,
 *     serverId: exampleServer.id,
 *     retentionInDays: 6,
 *     logMonitoringEnabled: false,
 *     storageAccountSubscriptionId: primaryAzurermSubscription.subscriptionId,
 * }, {
 *     dependsOn: [
 *         exampleAssignment,
 *         exampleAccount,
 *     ],
 * });
 * ```
 *
 * ## Import
 *
 * MS SQL Server Extended Auditing Policies can be imported using the `resource id`, e.g.
 *
 * ```sh
 * $ pulumi import azure:mssql/serverExtendedAuditingPolicy:ServerExtendedAuditingPolicy example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Sql/servers/sqlServer1/extendedAuditingSettings/default
 * ```
 */
class ServerExtendedAuditingPolicy extends pulumi.CustomResource {
    /**
     * Get an existing ServerExtendedAuditingPolicy 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 ServerExtendedAuditingPolicy(name, state, { ...opts, id: id });
    }
    /** @internal */
    static __pulumiType = 'azure:mssql/serverExtendedAuditingPolicy:ServerExtendedAuditingPolicy';
    /**
     * Returns true if the given object is an instance of ServerExtendedAuditingPolicy.  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'] === ServerExtendedAuditingPolicy.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["auditActionsAndGroups"] = state?.auditActionsAndGroups;
            resourceInputs["enabled"] = state?.enabled;
            resourceInputs["logMonitoringEnabled"] = state?.logMonitoringEnabled;
            resourceInputs["predicateExpression"] = state?.predicateExpression;
            resourceInputs["retentionInDays"] = state?.retentionInDays;
            resourceInputs["serverId"] = state?.serverId;
            resourceInputs["storageAccountAccessKey"] = state?.storageAccountAccessKey;
            resourceInputs["storageAccountAccessKeyIsSecondary"] = state?.storageAccountAccessKeyIsSecondary;
            resourceInputs["storageAccountSubscriptionId"] = state?.storageAccountSubscriptionId;
            resourceInputs["storageEndpoint"] = state?.storageEndpoint;
        }
        else {
            const args = argsOrState;
            if (args?.serverId === undefined && !opts.urn) {
                throw new Error("Missing required property 'serverId'");
            }
            resourceInputs["auditActionsAndGroups"] = args?.auditActionsAndGroups;
            resourceInputs["enabled"] = args?.enabled;
            resourceInputs["logMonitoringEnabled"] = args?.logMonitoringEnabled;
            resourceInputs["predicateExpression"] = args?.predicateExpression;
            resourceInputs["retentionInDays"] = args?.retentionInDays;
            resourceInputs["serverId"] = args?.serverId;
            resourceInputs["storageAccountAccessKey"] = args?.storageAccountAccessKey ? pulumi.secret(args.storageAccountAccessKey) : undefined;
            resourceInputs["storageAccountAccessKeyIsSecondary"] = args?.storageAccountAccessKeyIsSecondary;
            resourceInputs["storageAccountSubscriptionId"] = args?.storageAccountSubscriptionId ? pulumi.secret(args.storageAccountSubscriptionId) : undefined;
            resourceInputs["storageEndpoint"] = args?.storageEndpoint;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        const secretOpts = { additionalSecretOutputs: ["storageAccountAccessKey", "storageAccountSubscriptionId"] };
        opts = pulumi.mergeOptions(opts, secretOpts);
        super(ServerExtendedAuditingPolicy.__pulumiType, name, resourceInputs, opts);
    }
}
exports.ServerExtendedAuditingPolicy = ServerExtendedAuditingPolicy;
//# sourceMappingURL=serverExtendedAuditingPolicy.js.map