"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");
/**
 * Manages a private VPC connection with a GCP service provider. For more information see
 * [the official documentation](https://cloud.google.com/vpc/docs/configure-private-services-access#creating-connection)
 * and
 * [API](https://cloud.google.com/service-infrastructure/docs/service-networking/reference/rest/v1/services.connections).
 *
 * ## Example Usage
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * // Create a VPC network
 * const peeringNetwork = new gcp.compute.Network("peering_network", {name: "peering-network"});
 * // Create an IP address
 * const privateIpAlloc = new gcp.compute.GlobalAddress("private_ip_alloc", {
 *     name: "private-ip-alloc",
 *     purpose: "VPC_PEERING",
 *     addressType: "INTERNAL",
 *     prefixLength: 16,
 *     network: peeringNetwork.id,
 * });
 * // Create a private connection
 * const _default = new gcp.servicenetworking.Connection("default", {
 *     network: peeringNetwork.id,
 *     service: "servicenetworking.googleapis.com",
 *     reservedPeeringRanges: [privateIpAlloc.name],
 * });
 * // (Optional) Import or export custom routes
 * const peeringRoutes = new gcp.compute.NetworkPeeringRoutesConfig("peering_routes", {
 *     peering: _default.peering,
 *     network: peeringNetwork.name,
 *     importCustomRoutes: true,
 *     exportCustomRoutes: true,
 * });
 * ```
 *
 * ## Import
 *
 * ServiceNetworkingConnection can be imported using any of these accepted formats
 *
 * * `{{peering-network}}:{{service}}`
 *
 * * `projects/{{project}}/global/networks/{{peering-network}}:{{service}}`
 *
 * When using the `pulumi import` command, NAME_HERE can be imported using one of the formats above. For example:
 *
 * ```sh
 * $ pulumi import gcp:servicenetworking/connection:Connection default {{peering-network}}:{{service}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:servicenetworking/connection:Connection default /projects/{{project}}/global/networks/{{peering-network}}:{{service}}
 * ```
 */
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["deletionPolicy"] = state?.deletionPolicy;
            resourceInputs["network"] = state?.network;
            resourceInputs["peering"] = state?.peering;
            resourceInputs["reservedPeeringRanges"] = state?.reservedPeeringRanges;
            resourceInputs["service"] = state?.service;
            resourceInputs["updateOnCreationFail"] = state?.updateOnCreationFail;
        }
        else {
            const args = argsOrState;
            if (args?.network === undefined && !opts.urn) {
                throw new Error("Missing required property 'network'");
            }
            if (args?.reservedPeeringRanges === undefined && !opts.urn) {
                throw new Error("Missing required property 'reservedPeeringRanges'");
            }
            if (args?.service === undefined && !opts.urn) {
                throw new Error("Missing required property 'service'");
            }
            resourceInputs["deletionPolicy"] = args?.deletionPolicy;
            resourceInputs["network"] = args?.network;
            resourceInputs["reservedPeeringRanges"] = args?.reservedPeeringRanges;
            resourceInputs["service"] = args?.service;
            resourceInputs["updateOnCreationFail"] = args?.updateOnCreationFail;
            resourceInputs["peering"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        super(Connection.__pulumiType, name, resourceInputs, opts);
    }
}
exports.Connection = Connection;
/** @internal */
Connection.__pulumiType = 'gcp:servicenetworking/connection:Connection';
//# sourceMappingURL=connection.js.map