UNPKG

@natzka-oss/pulumi-netbox

Version:

A Pulumi package for creating and managing Netbox cloud resources.

89 lines 4.07 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! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.Token = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * From the [official documentation](https://docs.netbox.dev/en/stable/rest-api/authentication/#tokens): * * > A token is a unique identifier mapped to a NetBox user account. Each user may have one or more tokens which he or she can use for authentication when making REST API requests. To create a token, navigate to the API tokens page under your user profile. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as netbox from "@natzka-oss/pulumi-netbox"; * * const test = new netbox.auth.User("test", { * username: "johndoe", * password: "Abcdefghijkl1", * }); * const testBasic = new netbox.auth.Token("test_basic", { * userId: test.id, * key: "0123456789012345678901234567890123456789", * allowedIps: ["2.4.8.16/32"], * writeEnabled: false, * }); * ``` */ class Token extends pulumi.CustomResource { /** * Get an existing Token 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 Token(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of Token. 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'] === Token.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["allowedIps"] = state ? state.allowedIps : undefined; resourceInputs["description"] = state ? state.description : undefined; resourceInputs["expires"] = state ? state.expires : undefined; resourceInputs["key"] = state ? state.key : undefined; resourceInputs["lastUsed"] = state ? state.lastUsed : undefined; resourceInputs["userId"] = state ? state.userId : undefined; resourceInputs["writeEnabled"] = state ? state.writeEnabled : undefined; } else { const args = argsOrState; if ((!args || args.userId === undefined) && !opts.urn) { throw new Error("Missing required property 'userId'"); } resourceInputs["allowedIps"] = args ? args.allowedIps : undefined; resourceInputs["description"] = args ? args.description : undefined; resourceInputs["key"] = (args === null || args === void 0 ? void 0 : args.key) ? pulumi.secret(args.key) : undefined; resourceInputs["userId"] = args ? args.userId : undefined; resourceInputs["writeEnabled"] = args ? args.writeEnabled : undefined; resourceInputs["expires"] = undefined /*out*/; resourceInputs["lastUsed"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["key"] }; opts = pulumi.mergeOptions(opts, secretOpts); super(Token.__pulumiType, name, resourceInputs, opts); } } exports.Token = Token; /** @internal */ Token.__pulumiType = 'netbox:auth/token:Token'; //# sourceMappingURL=token.js.map