"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! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.User = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
 * A database user in an AlloyDB cluster.
 *
 * To get more information about User, see:
 *
 * * [API documentation](https://cloud.google.com/alloydb/docs/reference/rest/v1/projects.locations.clusters.users/create)
 * * How-to Guides
 *     * [AlloyDB](https://cloud.google.com/alloydb/docs/)
 *
 * > **Note:**  All arguments marked as write-only values will not be stored in the state: `passwordWo`.
 * Read more about Write-only Arguments.
 *
 * ## Example Usage
 *
 * ### Alloydb User Builtin
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const defaultCluster = new gcp.alloydb.Cluster("default", {
 *     clusterId: "alloydb-cluster",
 *     location: "us-central1",
 *     networkConfig: {
 *         network: defaultGoogleComputeNetwork.id,
 *     },
 *     initialUser: {
 *         password: "cluster_secret",
 *     },
 *     deletionProtection: false,
 * });
 * const defaultNetwork = new gcp.compute.Network("default", {name: "alloydb-network"});
 * const privateIpAlloc = new gcp.compute.GlobalAddress("private_ip_alloc", {
 *     name: "alloydb-cluster",
 *     addressType: "INTERNAL",
 *     purpose: "VPC_PEERING",
 *     prefixLength: 16,
 *     network: defaultNetwork.id,
 * });
 * const vpcConnection = new gcp.servicenetworking.Connection("vpc_connection", {
 *     network: defaultNetwork.id,
 *     service: "servicenetworking.googleapis.com",
 *     reservedPeeringRanges: [privateIpAlloc.name],
 * });
 * const _default = new gcp.alloydb.Instance("default", {
 *     cluster: defaultCluster.name,
 *     instanceId: "alloydb-instance",
 *     instanceType: "PRIMARY",
 * }, {
 *     dependsOn: [vpcConnection],
 * });
 * const project = gcp.organizations.getProject({});
 * const user1 = new gcp.alloydb.User("user1", {
 *     cluster: defaultCluster.name,
 *     userId: "user1",
 *     userType: "ALLOYDB_BUILT_IN",
 *     password: "user_secret",
 *     databaseRoles: ["alloydbsuperuser"],
 * }, {
 *     dependsOn: [_default],
 * });
 * ```
 * ### Alloydb User Iam
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const defaultNetwork = new gcp.compute.Network("default", {name: "alloydb-network"});
 * const defaultCluster = new gcp.alloydb.Cluster("default", {
 *     clusterId: "alloydb-cluster",
 *     location: "us-central1",
 *     networkConfig: {
 *         network: defaultNetwork.id,
 *     },
 *     initialUser: {
 *         password: "cluster_secret",
 *     },
 *     deletionProtection: false,
 * });
 * const privateIpAlloc = new gcp.compute.GlobalAddress("private_ip_alloc", {
 *     name: "alloydb-cluster",
 *     addressType: "INTERNAL",
 *     purpose: "VPC_PEERING",
 *     prefixLength: 16,
 *     network: defaultNetwork.id,
 * });
 * const vpcConnection = new gcp.servicenetworking.Connection("vpc_connection", {
 *     network: defaultNetwork.id,
 *     service: "servicenetworking.googleapis.com",
 *     reservedPeeringRanges: [privateIpAlloc.name],
 * });
 * const _default = new gcp.alloydb.Instance("default", {
 *     cluster: defaultCluster.name,
 *     instanceId: "alloydb-instance",
 *     instanceType: "PRIMARY",
 * }, {
 *     dependsOn: [vpcConnection],
 * });
 * const project = gcp.organizations.getProject({});
 * const user2 = new gcp.alloydb.User("user2", {
 *     cluster: defaultCluster.name,
 *     userId: "user2@foo.com",
 *     userType: "ALLOYDB_IAM_USER",
 *     databaseRoles: ["alloydbiamuser"],
 * }, {
 *     dependsOn: [_default],
 * });
 * ```
 *
 * ## Import
 *
 * User can be imported using any of these accepted formats:
 *
 * * `projects/{{project}}/locations/{{location}}/clusters/{{cluster}}/users/{{user_id}}`
 *
 * * `{{project}}/{{location}}/{{cluster}}/{{user_id}}`
 *
 * * `{{location}}/{{cluster}}/{{user_id}}`
 *
 * When using the `pulumi import` command, User can be imported using one of the formats above. For example:
 *
 * ```sh
 * $ pulumi import gcp:alloydb/user:User default projects/{{project}}/locations/{{location}}/clusters/{{cluster}}/users/{{user_id}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:alloydb/user:User default {{project}}/{{location}}/{{cluster}}/{{user_id}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:alloydb/user:User default {{location}}/{{cluster}}/{{user_id}}
 * ```
 */
class User extends pulumi.CustomResource {
    /**
     * Get an existing User 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 User(name, state, { ...opts, id: id });
    }
    /**
     * Returns true if the given object is an instance of User.  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'] === User.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["cluster"] = state?.cluster;
            resourceInputs["databaseRoles"] = state?.databaseRoles;
            resourceInputs["name"] = state?.name;
            resourceInputs["password"] = state?.password;
            resourceInputs["passwordWo"] = state?.passwordWo;
            resourceInputs["passwordWoVersion"] = state?.passwordWoVersion;
            resourceInputs["userId"] = state?.userId;
            resourceInputs["userType"] = state?.userType;
        }
        else {
            const args = argsOrState;
            if (args?.cluster === undefined && !opts.urn) {
                throw new Error("Missing required property 'cluster'");
            }
            if (args?.userId === undefined && !opts.urn) {
                throw new Error("Missing required property 'userId'");
            }
            if (args?.userType === undefined && !opts.urn) {
                throw new Error("Missing required property 'userType'");
            }
            resourceInputs["cluster"] = args?.cluster;
            resourceInputs["databaseRoles"] = args?.databaseRoles;
            resourceInputs["password"] = args?.password ? pulumi.secret(args.password) : undefined;
            resourceInputs["passwordWo"] = args?.passwordWo ? pulumi.secret(args.passwordWo) : undefined;
            resourceInputs["passwordWoVersion"] = args?.passwordWoVersion;
            resourceInputs["userId"] = args?.userId;
            resourceInputs["userType"] = args?.userType;
            resourceInputs["name"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        const secretOpts = { additionalSecretOutputs: ["password", "passwordWo"] };
        opts = pulumi.mergeOptions(opts, secretOpts);
        super(User.__pulumiType, name, resourceInputs, opts);
    }
}
exports.User = User;
/** @internal */
User.__pulumiType = 'gcp:alloydb/user:User';
//# sourceMappingURL=user.js.map