"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.EngineSplitTraffic = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
 * Traffic routing configuration for versions within a single service. Traffic splits define how traffic directed to the service is assigned to versions.
 *
 * To get more information about ServiceSplitTraffic, see:
 *
 * * [API documentation](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services)
 *
 * ## Example Usage
 *
 * ### App Engine Service Split Traffic
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const bucket = new gcp.storage.Bucket("bucket", {
 *     name: "appengine-static-content",
 *     location: "US",
 * });
 * const object = new gcp.storage.BucketObject("object", {
 *     name: "hello-world.zip",
 *     bucket: bucket.name,
 *     source: new pulumi.asset.FileAsset("./test-fixtures/hello-world.zip"),
 * });
 * const liveappV1 = new gcp.appengine.StandardAppVersion("liveapp_v1", {
 *     versionId: "v1",
 *     service: "liveapp",
 *     deleteServiceOnDestroy: true,
 *     runtime: "nodejs20",
 *     entrypoint: {
 *         shell: "node ./app.js",
 *     },
 *     deployment: {
 *         zip: {
 *             sourceUrl: pulumi.interpolate`https://storage.googleapis.com/${bucket.name}/${object.name}`,
 *         },
 *     },
 *     envVariables: {
 *         port: "8080",
 *     },
 * });
 * const liveappV2 = new gcp.appengine.StandardAppVersion("liveapp_v2", {
 *     versionId: "v2",
 *     service: "liveapp",
 *     noopOnDestroy: true,
 *     runtime: "nodejs20",
 *     entrypoint: {
 *         shell: "node ./app.js",
 *     },
 *     deployment: {
 *         zip: {
 *             sourceUrl: pulumi.interpolate`https://storage.googleapis.com/${bucket.name}/${object.name}`,
 *         },
 *     },
 *     envVariables: {
 *         port: "8080",
 *     },
 * });
 * const liveapp = new gcp.appengine.EngineSplitTraffic("liveapp", {
 *     service: liveappV2.service,
 *     migrateTraffic: false,
 *     split: {
 *         shardBy: "IP",
 *         allocations: pulumi.all([liveappV1.versionId, liveappV2.versionId]).apply(([liveappV1VersionId, liveappV2VersionId]) => {
 *             [liveappV1VersionId]: 0.75,
 *             [liveappV2VersionId]: 0.25,
 *         }),
 *     },
 * });
 * ```
 *
 * ## Import
 *
 * ServiceSplitTraffic can be imported using any of these accepted formats:
 *
 * * `apps/{{project}}/services/{{service}}`
 *
 * * `{{project}}/{{service}}`
 *
 * * `{{service}}`
 *
 * When using the `pulumi import` command, ServiceSplitTraffic can be imported using one of the formats above. For example:
 *
 * ```sh
 * $ pulumi import gcp:appengine/engineSplitTraffic:EngineSplitTraffic default apps/{{project}}/services/{{service}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:appengine/engineSplitTraffic:EngineSplitTraffic default {{project}}/{{service}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:appengine/engineSplitTraffic:EngineSplitTraffic default {{service}}
 * ```
 */
class EngineSplitTraffic extends pulumi.CustomResource {
    /**
     * Get an existing EngineSplitTraffic 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 EngineSplitTraffic(name, state, { ...opts, id: id });
    }
    /**
     * Returns true if the given object is an instance of EngineSplitTraffic.  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'] === EngineSplitTraffic.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["migrateTraffic"] = state?.migrateTraffic;
            resourceInputs["project"] = state?.project;
            resourceInputs["service"] = state?.service;
            resourceInputs["split"] = state?.split;
        }
        else {
            const args = argsOrState;
            if (args?.service === undefined && !opts.urn) {
                throw new Error("Missing required property 'service'");
            }
            if (args?.split === undefined && !opts.urn) {
                throw new Error("Missing required property 'split'");
            }
            resourceInputs["migrateTraffic"] = args?.migrateTraffic;
            resourceInputs["project"] = args?.project;
            resourceInputs["service"] = args?.service;
            resourceInputs["split"] = args?.split;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        super(EngineSplitTraffic.__pulumiType, name, resourceInputs, opts);
    }
}
exports.EngineSplitTraffic = EngineSplitTraffic;
/** @internal */
EngineSplitTraffic.__pulumiType = 'gcp:appengine/engineSplitTraffic:EngineSplitTraffic';
//# sourceMappingURL=engineSplitTraffic.js.map