"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.Connection = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
 * A connection for GitHub, GitHub Enterprise, GitLab, and GitLab Enterprise.
 *
 * To get more information about Connection, see:
 *
 * * [API documentation](https://cloud.google.com/developer-connect/docs/api/reference/rest/v1/projects.locations.connections)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/developer-connect/docs/overview)
 *
 * ## Example Usage
 *
 * ### Developer Connect Connection New
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * // Setup permissions. Only needed once per project
 * const devconnect_p4sa = new gcp.projects.ServiceIdentity("devconnect-p4sa", {service: "developerconnect.googleapis.com"});
 * const devconnect_secret = new gcp.projects.IAMMember("devconnect-secret", {
 *     project: "my-project-name",
 *     role: "roles/secretmanager.admin",
 *     member: devconnect_p4sa.member,
 * });
 * const my_connection = new gcp.developerconnect.Connection("my-connection", {
 *     location: "us-central1",
 *     connectionId: "tf-test-connection-new",
 *     githubConfig: {
 *         githubApp: "FIREBASE",
 *     },
 * }, {
 *     dependsOn: [devconnect_secret],
 * });
 * export const nextSteps = my_connection.installationStates;
 * ```
 * ### Developer Connect Connection Existing Credentials
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const my_connection = new gcp.developerconnect.Connection("my-connection", {
 *     location: "us-central1",
 *     connectionId: "tf-test-connection-cred",
 *     githubConfig: {
 *         githubApp: "DEVELOPER_CONNECT",
 *         authorizerCredential: {
 *             oauthTokenSecretVersion: "projects/your-project/secrets/your-secret-id/versions/latest",
 *         },
 *     },
 * });
 * export const nextSteps = my_connection.installationStates;
 * ```
 * ### Developer Connect Connection Existing Installation
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * import * as std from "@pulumi/std";
 *
 * const github_token_secret = new gcp.secretmanager.Secret("github-token-secret", {
 *     secretId: "github-token-secret",
 *     replication: {
 *         auto: {},
 *     },
 * });
 * const github_token_secret_version = new gcp.secretmanager.SecretVersion("github-token-secret-version", {
 *     secret: github_token_secret.id,
 *     secretData: std.file({
 *         input: "my-github-token.txt",
 *     }).then(invoke => invoke.result),
 * });
 * const devconnect_p4sa = new gcp.projects.ServiceIdentity("devconnect-p4sa", {service: "developerconnect.googleapis.com"});
 * const p4sa_secretAccessor = gcp.organizations.getIAMPolicyOutput({
 *     bindings: [{
 *         role: "roles/secretmanager.secretAccessor",
 *         members: [devconnect_p4sa.member],
 *     }],
 * });
 * const policy = new gcp.secretmanager.SecretIamPolicy("policy", {
 *     secretId: github_token_secret.secretId,
 *     policyData: p4sa_secretAccessor.apply(p4sa_secretAccessor => p4sa_secretAccessor.policyData),
 * });
 * const my_connection = new gcp.developerconnect.Connection("my-connection", {
 *     location: "us-central1",
 *     connectionId: "my-connection",
 *     githubConfig: {
 *         githubApp: "DEVELOPER_CONNECT",
 *         appInstallationId: "123123",
 *         authorizerCredential: {
 *             oauthTokenSecretVersion: github_token_secret_version.id,
 *         },
 *     },
 * });
 * ```
 * ### Developer Connect Connection Github
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const my_connection = new gcp.developerconnect.Connection("my-connection", {
 *     location: "us-central1",
 *     connectionId: "tf-test-connection",
 *     githubConfig: {
 *         githubApp: "DEVELOPER_CONNECT",
 *         authorizerCredential: {
 *             oauthTokenSecretVersion: "projects/devconnect-terraform-creds/secrets/tf-test-do-not-change-github-oauthtoken-e0b9e7/versions/1",
 *         },
 *     },
 * });
 * ```
 * ### Developer Connect Connection Github Doc
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * import * as std from "@pulumi/std";
 *
 * const github_token_secret = new gcp.secretmanager.Secret("github-token-secret", {
 *     secretId: "github-token-secret",
 *     replication: {
 *         auto: {},
 *     },
 * });
 * const github_token_secret_version = new gcp.secretmanager.SecretVersion("github-token-secret-version", {
 *     secret: github_token_secret.id,
 *     secretData: std.file({
 *         input: "my-github-token.txt",
 *     }).then(invoke => invoke.result),
 * });
 * const p4sa_secretAccessor = gcp.organizations.getIAMPolicy({
 *     bindings: [{
 *         role: "roles/secretmanager.secretAccessor",
 *         members: ["serviceAccount:service-123456789@gcp-sa-devconnect.iam.gserviceaccount.com"],
 *     }],
 * });
 * const policy = new gcp.secretmanager.SecretIamPolicy("policy", {
 *     secretId: github_token_secret.secretId,
 *     policyData: p4sa_secretAccessor.then(p4sa_secretAccessor => p4sa_secretAccessor.policyData),
 * });
 * const my_connection = new gcp.developerconnect.Connection("my-connection", {
 *     location: "us-central1",
 *     connectionId: "my-connection",
 *     githubConfig: {
 *         githubApp: "DEVELOPER_CONNECT",
 *         appInstallationId: "123123",
 *         authorizerCredential: {
 *             oauthTokenSecretVersion: github_token_secret_version.id,
 *         },
 *     },
 * });
 * ```
 * ### Developer Connect Connection Github Enterprise
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const my_connection = new gcp.developerconnect.Connection("my-connection", {
 *     location: "us-central1",
 *     connectionId: "tf-test-connection",
 *     githubEnterpriseConfig: {
 *         hostUri: "https://ghe.proctor-staging-test.com",
 *         appId: "864434",
 *         privateKeySecretVersion: "projects/devconnect-terraform-creds/secrets/tf-test-ghe-do-not-change-ghe-private-key-f522d2/versions/latest",
 *         webhookSecretSecretVersion: "projects/devconnect-terraform-creds/secrets/tf-test-ghe-do-not-change-ghe-webhook-secret-3c806f/versions/latest",
 *         appInstallationId: "837537",
 *     },
 * });
 * ```
 * ### Developer Connect Connection Github Enterprise Doc
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * import * as std from "@pulumi/std";
 *
 * const private_key_secret = new gcp.secretmanager.Secret("private-key-secret", {
 *     secretId: "ghe-pk-secret",
 *     replication: {
 *         auto: {},
 *     },
 * });
 * const private_key_secret_version = new gcp.secretmanager.SecretVersion("private-key-secret-version", {
 *     secret: private_key_secret.id,
 *     secretData: std.file({
 *         input: "private-key.pem",
 *     }).then(invoke => invoke.result),
 * });
 * const webhook_secret_secret = new gcp.secretmanager.Secret("webhook-secret-secret", {
 *     secretId: "ghe-token-secret",
 *     replication: {
 *         auto: {},
 *     },
 * });
 * const webhook_secret_secret_version = new gcp.secretmanager.SecretVersion("webhook-secret-secret-version", {
 *     secret: webhook_secret_secret.id,
 *     secretData: "<webhook-secret-data>",
 * });
 * const p4sa_secretAccessor = gcp.organizations.getIAMPolicy({
 *     bindings: [{
 *         role: "roles/secretmanager.secretAccessor",
 *         members: ["serviceAccount:service-123456789@gcp-sa-devconnect.iam.gserviceaccount.com"],
 *     }],
 * });
 * const policy_pk = new gcp.secretmanager.SecretIamPolicy("policy-pk", {
 *     secretId: private_key_secret.secretId,
 *     policyData: p4sa_secretAccessor.then(p4sa_secretAccessor => p4sa_secretAccessor.policyData),
 * });
 * const policy_whs = new gcp.secretmanager.SecretIamPolicy("policy-whs", {
 *     secretId: webhook_secret_secret.secretId,
 *     policyData: p4sa_secretAccessor.then(p4sa_secretAccessor => p4sa_secretAccessor.policyData),
 * });
 * const my_connection = new gcp.developerconnect.Connection("my-connection", {
 *     location: "us-central1",
 *     connectionId: "my-connection",
 *     githubEnterpriseConfig: {
 *         hostUri: "https://ghe.com",
 *         privateKeySecretVersion: private_key_secret_version.id,
 *         webhookSecretSecretVersion: webhook_secret_secret_version.id,
 *         appId: "100",
 *         appInstallationId: "123123",
 *     },
 * }, {
 *     dependsOn: [
 *         policy_pk,
 *         policy_whs,
 *     ],
 * });
 * ```
 * ### Developer Connect Connection Gitlab
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const my_connection = new gcp.developerconnect.Connection("my-connection", {
 *     location: "us-central1",
 *     connectionId: "tf-test-connection",
 *     gitlabConfig: {
 *         webhookSecretSecretVersion: "projects/devconnect-terraform-creds/secrets/gitlab-webhook/versions/latest",
 *         readAuthorizerCredential: {
 *             userTokenSecretVersion: "projects/devconnect-terraform-creds/secrets/gitlab-read-cred/versions/latest",
 *         },
 *         authorizerCredential: {
 *             userTokenSecretVersion: "projects/devconnect-terraform-creds/secrets/gitlab-auth-cred/versions/latest",
 *         },
 *     },
 * });
 * ```
 * ### Developer Connect Connection Gitlab Enterprise
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const my_connection = new gcp.developerconnect.Connection("my-connection", {
 *     location: "us-central1",
 *     connectionId: "tf-test-connection",
 *     gitlabEnterpriseConfig: {
 *         hostUri: "https://gle-us-central1.gcb-test.com",
 *         webhookSecretSecretVersion: "projects/devconnect-terraform-creds/secrets/gitlab-enterprise-webhook/versions/latest",
 *         readAuthorizerCredential: {
 *             userTokenSecretVersion: "projects/devconnect-terraform-creds/secrets/gitlab-enterprise-read-cred/versions/latest",
 *         },
 *         authorizerCredential: {
 *             userTokenSecretVersion: "projects/devconnect-terraform-creds/secrets/gitlab-enterprise-auth-cred/versions/latest",
 *         },
 *     },
 * });
 * ```
 * ### Developer Connect Connection Bbc
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const my_connection = new gcp.developerconnect.Connection("my-connection", {
 *     location: "us-central1",
 *     connectionId: "tf-test-connection",
 *     bitbucketCloudConfig: {
 *         workspace: "proctor-test",
 *         webhookSecretSecretVersion: "projects/devconnect-terraform-creds/secrets/bbc-webhook/versions/latest",
 *         readAuthorizerCredential: {
 *             userTokenSecretVersion: "projects/devconnect-terraform-creds/secrets/bbc-read-token/versions/latest",
 *         },
 *         authorizerCredential: {
 *             userTokenSecretVersion: "projects/devconnect-terraform-creds/secrets/bbc-auth-token/versions/latest",
 *         },
 *     },
 * });
 * ```
 * ### Developer Connect Connection Bbdc
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const my_connection = new gcp.developerconnect.Connection("my-connection", {
 *     location: "us-central1",
 *     connectionId: "tf-test-connection",
 *     bitbucketDataCenterConfig: {
 *         hostUri: "https://bitbucket-us-central.gcb-test.com",
 *         webhookSecretSecretVersion: "projects/devconnect-terraform-creds/secrets/bbdc-webhook/versions/latest",
 *         readAuthorizerCredential: {
 *             userTokenSecretVersion: "projects/devconnect-terraform-creds/secrets/bbdc-read-token/versions/latest",
 *         },
 *         authorizerCredential: {
 *             userTokenSecretVersion: "projects/devconnect-terraform-creds/secrets/bbdc-auth-token/versions/latest",
 *         },
 *     },
 * });
 * ```
 * ## Import
 *
 * Connection can be imported using any of these accepted formats:
 *
 * * `projects/{{project}}/locations/{{location}}/connections/{{connection_id}}`
 *
 * * `{{project}}/{{location}}/{{connection_id}}`
 *
 * * `{{location}}/{{connection_id}}`
 *
 * When using the `pulumi import` command, Connection can be imported using one of the formats above. For example:
 *
 * ```sh
 * $ pulumi import gcp:developerconnect/connection:Connection default projects/{{project}}/locations/{{location}}/connections/{{connection_id}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:developerconnect/connection:Connection default {{project}}/{{location}}/{{connection_id}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:developerconnect/connection:Connection default {{location}}/{{connection_id}}
 * ```
 */
class Connection extends pulumi.CustomResource {
    /**
     * Get an existing Connection 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 Connection(name, state, { ...opts, id: id });
    }
    /**
     * Returns true if the given object is an instance of Connection.  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'] === Connection.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["annotations"] = state?.annotations;
            resourceInputs["bitbucketCloudConfig"] = state?.bitbucketCloudConfig;
            resourceInputs["bitbucketDataCenterConfig"] = state?.bitbucketDataCenterConfig;
            resourceInputs["connectionId"] = state?.connectionId;
            resourceInputs["createTime"] = state?.createTime;
            resourceInputs["cryptoKeyConfig"] = state?.cryptoKeyConfig;
            resourceInputs["deleteTime"] = state?.deleteTime;
            resourceInputs["disabled"] = state?.disabled;
            resourceInputs["effectiveAnnotations"] = state?.effectiveAnnotations;
            resourceInputs["effectiveLabels"] = state?.effectiveLabels;
            resourceInputs["etag"] = state?.etag;
            resourceInputs["githubConfig"] = state?.githubConfig;
            resourceInputs["githubEnterpriseConfig"] = state?.githubEnterpriseConfig;
            resourceInputs["gitlabConfig"] = state?.gitlabConfig;
            resourceInputs["gitlabEnterpriseConfig"] = state?.gitlabEnterpriseConfig;
            resourceInputs["installationStates"] = state?.installationStates;
            resourceInputs["labels"] = state?.labels;
            resourceInputs["location"] = state?.location;
            resourceInputs["name"] = state?.name;
            resourceInputs["project"] = state?.project;
            resourceInputs["pulumiLabels"] = state?.pulumiLabels;
            resourceInputs["reconciling"] = state?.reconciling;
            resourceInputs["uid"] = state?.uid;
            resourceInputs["updateTime"] = state?.updateTime;
        }
        else {
            const args = argsOrState;
            if (args?.connectionId === undefined && !opts.urn) {
                throw new Error("Missing required property 'connectionId'");
            }
            if (args?.location === undefined && !opts.urn) {
                throw new Error("Missing required property 'location'");
            }
            resourceInputs["annotations"] = args?.annotations;
            resourceInputs["bitbucketCloudConfig"] = args?.bitbucketCloudConfig;
            resourceInputs["bitbucketDataCenterConfig"] = args?.bitbucketDataCenterConfig;
            resourceInputs["connectionId"] = args?.connectionId;
            resourceInputs["cryptoKeyConfig"] = args?.cryptoKeyConfig;
            resourceInputs["disabled"] = args?.disabled;
            resourceInputs["etag"] = args?.etag;
            resourceInputs["githubConfig"] = args?.githubConfig;
            resourceInputs["githubEnterpriseConfig"] = args?.githubEnterpriseConfig;
            resourceInputs["gitlabConfig"] = args?.gitlabConfig;
            resourceInputs["gitlabEnterpriseConfig"] = args?.gitlabEnterpriseConfig;
            resourceInputs["labels"] = args?.labels;
            resourceInputs["location"] = args?.location;
            resourceInputs["project"] = args?.project;
            resourceInputs["createTime"] = undefined /*out*/;
            resourceInputs["deleteTime"] = undefined /*out*/;
            resourceInputs["effectiveAnnotations"] = undefined /*out*/;
            resourceInputs["effectiveLabels"] = undefined /*out*/;
            resourceInputs["installationStates"] = undefined /*out*/;
            resourceInputs["name"] = undefined /*out*/;
            resourceInputs["pulumiLabels"] = undefined /*out*/;
            resourceInputs["reconciling"] = undefined /*out*/;
            resourceInputs["uid"] = undefined /*out*/;
            resourceInputs["updateTime"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        const secretOpts = { additionalSecretOutputs: ["effectiveLabels", "pulumiLabels"] };
        opts = pulumi.mergeOptions(opts, secretOpts);
        super(Connection.__pulumiType, name, resourceInputs, opts);
    }
}
exports.Connection = Connection;
/** @internal */
Connection.__pulumiType = 'gcp:developerconnect/connection:Connection';
//# sourceMappingURL=connection.js.map