UNPKG

@pulumi/kong

Version:

A Pulumi package for creating and managing Kong resources.

183 lines 6.36 kB
"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! *** var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Plugin = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("./utilities")); /** * ## # kong.Plugin * * The plugin resource maps directly onto the json for the API endpoint in Kong. For more information on the parameters [see the Kong Api create documentation](https://docs.konghq.com/gateway-oss/2.5.x/admin-api/#plugin-object). * The `configJson` is passed through to the plugin to configure it as is. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as kong from "@pulumi/kong"; * * const rateLimit = new kong.Plugin("rate_limit", { * name: "rate-limiting", * configJson: `\\t{ * \\t\\t\\"second\\": 5, * \\t\\t\\"hour\\" : 1000 * \\t} * `, * }); * ``` * To apply a plugin to a consumer use the `consumerId` property, for example: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as kong from "@pulumi/kong"; * * const pluginConsumer = new kong.Consumer("plugin_consumer", { * username: "PluginUser", * customId: "567", * }); * const rateLimit = new kong.Plugin("rate_limit", { * name: "rate-limiting", * consumerId: pluginConsumer.id, * configJson: `\\t{ * \\t\\t\\"second\\": 5, * \\t\\t\\"hour\\" : 1000 * \\t} * `, * }); * ``` * * To apply a plugin to a service use the `serviceId` property, for example: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as kong from "@pulumi/kong"; * * const service = new kong.Service("service", { * name: "test", * protocol: "http", * host: "test.org", * }); * const rateLimit = new kong.Plugin("rate_limit", { * name: "rate-limiting", * serviceId: service.id, * configJson: `\\t{ * \\t\\t\\"second\\": 10, * \\t\\t\\"hour\\" : 2000 * \\t} * `, * }); * ``` * * To apply a plugin to a route use the `routeId` property, for example: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as kong from "@pulumi/kong"; * * const service = new kong.Service("service", { * name: "test", * protocol: "http", * host: "test.org", * }); * const rateLimit = new kong.Plugin("rate_limit", { * name: "rate-limiting", * enabled: true, * serviceId: service.id, * configJson: `\\t{ * \\t\\t\\"second\\": 11, * \\t\\t\\"hour\\" : 4000 * \\t} * `, * }); * ``` * * ## Import * * To import a plugin: * * ```sh * $ pulumi import kong:index/plugin:Plugin <plugin_identifier> <plugin_id> * ``` */ class Plugin extends pulumi.CustomResource { /** * Get an existing Plugin 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 Plugin(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'kong:index/plugin:Plugin'; /** * Returns true if the given object is an instance of Plugin. 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'] === Plugin.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["computedConfig"] = state?.computedConfig; resourceInputs["configJson"] = state?.configJson; resourceInputs["consumerId"] = state?.consumerId; resourceInputs["enabled"] = state?.enabled; resourceInputs["name"] = state?.name; resourceInputs["routeId"] = state?.routeId; resourceInputs["serviceId"] = state?.serviceId; resourceInputs["strictMatch"] = state?.strictMatch; resourceInputs["tags"] = state?.tags; } else { const args = argsOrState; resourceInputs["configJson"] = args?.configJson; resourceInputs["consumerId"] = args?.consumerId; resourceInputs["enabled"] = args?.enabled; resourceInputs["name"] = args?.name; resourceInputs["routeId"] = args?.routeId; resourceInputs["serviceId"] = args?.serviceId; resourceInputs["strictMatch"] = args?.strictMatch; resourceInputs["tags"] = args?.tags; resourceInputs["computedConfig"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Plugin.__pulumiType, name, resourceInputs, opts); } } exports.Plugin = Plugin; //# sourceMappingURL=plugin.js.map