"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.BranchRule = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
 * BranchRule is the protection rule to enforce pre-defined rules on designated branches within a repository.
 *
 * To get more information about BranchRule, see:
 *
 * * [API documentation](https://cloud.google.com/secure-source-manager/docs/reference/rest/v1/projects.locations.repositories.branchRules)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/secure-source-manager/docs/overview)
 *
 * ## Example Usage
 *
 * ### Secure Source Manager Branch Rule Basic
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const instance = new gcp.securesourcemanager.Instance("instance", {
 *     location: "us-central1",
 *     instanceId: "my-basic-instance",
 *     deletionPolicy: "PREVENT",
 * });
 * const repository = new gcp.securesourcemanager.Repository("repository", {
 *     repositoryId: "my-basic-repository",
 *     location: instance.location,
 *     instance: instance.name,
 *     deletionPolicy: "PREVENT",
 * });
 * const basic = new gcp.securesourcemanager.BranchRule("basic", {
 *     branchRuleId: "my-basic-branchrule",
 *     repositoryId: repository.repositoryId,
 *     location: repository.location,
 *     includePattern: "main",
 * });
 * ```
 * ### Secure Source Manager Branch Rule With Fields
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const instance = new gcp.securesourcemanager.Instance("instance", {
 *     location: "us-central1",
 *     instanceId: "my-initial-instance",
 *     deletionPolicy: "PREVENT",
 * });
 * const repository = new gcp.securesourcemanager.Repository("repository", {
 *     repositoryId: "my-initial-repository",
 *     instance: instance.name,
 *     location: instance.location,
 *     deletionPolicy: "PREVENT",
 * });
 * const _default = new gcp.securesourcemanager.BranchRule("default", {
 *     branchRuleId: "my-initial-branchrule",
 *     location: repository.location,
 *     repositoryId: repository.repositoryId,
 *     includePattern: "test",
 *     minimumApprovalsCount: 2,
 *     minimumReviewsCount: 2,
 *     requireCommentsResolved: true,
 *     requireLinearHistory: true,
 *     requirePullRequest: true,
 *     disabled: false,
 *     allowStaleReviews: false,
 * });
 * ```
 *
 * ## Import
 *
 * BranchRule can be imported using any of these accepted formats:
 *
 * * `projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}/branchRules/{{branch_rule_id}}`
 *
 * * `{{project}}/{{location}}/{{repository_id}}/{{branch_rule_id}}`
 *
 * * `{{location}}/{{repository_id}}/{{branch_rule_id}}`
 *
 * * `{{branch_rule_id}}`
 *
 * When using the `pulumi import` command, BranchRule can be imported using one of the formats above. For example:
 *
 * ```sh
 * $ pulumi import gcp:securesourcemanager/branchRule:BranchRule default projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}/branchRules/{{branch_rule_id}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:securesourcemanager/branchRule:BranchRule default {{project}}/{{location}}/{{repository_id}}/{{branch_rule_id}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:securesourcemanager/branchRule:BranchRule default {{location}}/{{repository_id}}/{{branch_rule_id}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:securesourcemanager/branchRule:BranchRule default {{branch_rule_id}}
 * ```
 */
class BranchRule extends pulumi.CustomResource {
    /**
     * Get an existing BranchRule 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 BranchRule(name, state, { ...opts, id: id });
    }
    /**
     * Returns true if the given object is an instance of BranchRule.  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'] === BranchRule.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["allowStaleReviews"] = state?.allowStaleReviews;
            resourceInputs["branchRuleId"] = state?.branchRuleId;
            resourceInputs["createTime"] = state?.createTime;
            resourceInputs["disabled"] = state?.disabled;
            resourceInputs["includePattern"] = state?.includePattern;
            resourceInputs["location"] = state?.location;
            resourceInputs["minimumApprovalsCount"] = state?.minimumApprovalsCount;
            resourceInputs["minimumReviewsCount"] = state?.minimumReviewsCount;
            resourceInputs["name"] = state?.name;
            resourceInputs["project"] = state?.project;
            resourceInputs["repositoryId"] = state?.repositoryId;
            resourceInputs["requireCommentsResolved"] = state?.requireCommentsResolved;
            resourceInputs["requireLinearHistory"] = state?.requireLinearHistory;
            resourceInputs["requirePullRequest"] = state?.requirePullRequest;
            resourceInputs["uid"] = state?.uid;
            resourceInputs["updateTime"] = state?.updateTime;
        }
        else {
            const args = argsOrState;
            if (args?.branchRuleId === undefined && !opts.urn) {
                throw new Error("Missing required property 'branchRuleId'");
            }
            if (args?.includePattern === undefined && !opts.urn) {
                throw new Error("Missing required property 'includePattern'");
            }
            if (args?.location === undefined && !opts.urn) {
                throw new Error("Missing required property 'location'");
            }
            if (args?.repositoryId === undefined && !opts.urn) {
                throw new Error("Missing required property 'repositoryId'");
            }
            resourceInputs["allowStaleReviews"] = args?.allowStaleReviews;
            resourceInputs["branchRuleId"] = args?.branchRuleId;
            resourceInputs["disabled"] = args?.disabled;
            resourceInputs["includePattern"] = args?.includePattern;
            resourceInputs["location"] = args?.location;
            resourceInputs["minimumApprovalsCount"] = args?.minimumApprovalsCount;
            resourceInputs["minimumReviewsCount"] = args?.minimumReviewsCount;
            resourceInputs["project"] = args?.project;
            resourceInputs["repositoryId"] = args?.repositoryId;
            resourceInputs["requireCommentsResolved"] = args?.requireCommentsResolved;
            resourceInputs["requireLinearHistory"] = args?.requireLinearHistory;
            resourceInputs["requirePullRequest"] = args?.requirePullRequest;
            resourceInputs["createTime"] = undefined /*out*/;
            resourceInputs["name"] = undefined /*out*/;
            resourceInputs["uid"] = undefined /*out*/;
            resourceInputs["updateTime"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        super(BranchRule.__pulumiType, name, resourceInputs, opts);
    }
}
exports.BranchRule = BranchRule;
/** @internal */
BranchRule.__pulumiType = 'gcp:securesourcemanager/branchRule:BranchRule';
//# sourceMappingURL=branchRule.js.map