@pulumi/vsphere
Version:
A Pulumi package for creating vsphere resources
141 lines • 5.54 kB
JavaScript
;
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.Folder = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* The `vsphere.Folder` resource can be used to manage vSphere inventory folders.
* The resource supports creating folders of the 5 major types - datacenter
* folders, host and cluster folders, virtual machine folders, storage folders,
* and network folders.
*
* Paths are always relative to the specific type of folder you are creating.
* A subfolder is discovered by parsing the relative path specified in `path`, so
* `foo/bar` will create a folder named `bar` in the parent folder `foo`, as long
* as the folder `foo` exists.
*
* ## Example Usage
*
* The basic example below creates a virtual machine folder named
* `test-folder` in the default datacenter's VM hierarchy.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as vsphere from "@pulumi/vsphere";
*
* const datacenter = vsphere.getDatacenter({
* name: vsphereDatacenter,
* });
* const folder = new vsphere.Folder("folder", {
* path: "test-folder",
* type: "vm",
* datacenterId: datacenter.then(datacenter => datacenter.id),
* });
* ```
*
* ### Example with Sub-folders
*
* The below example builds off of the above by first creating a folder named
* `test-parent`, and then locating `test-folder` in that
* folder. To ensure the parent is created first, we create an interpolation
* dependency off the parent's `path` attribute.
*
* Note that if you change parents (for example, went from the above basic
* configuration to this one), your folder will be moved to be under the correct
* parent.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as vsphere from "@pulumi/vsphere";
*
* const datacenter = vsphere.getDatacenter({
* name: vsphereDatacenter,
* });
* const parent = new vsphere.Folder("parent", {
* path: "test-parent",
* type: "vm",
* datacenterId: datacenter.then(datacenter => datacenter.id),
* });
* const folder = new vsphere.Folder("folder", {
* path: pulumi.interpolate`${parent.path}/test-folder`,
* type: "vm",
* datacenterId: datacenter.then(datacenter => datacenter.id),
* });
* ```
*
* ## Import
*
* An existing folder can be imported into this resource via
*
* its full path, via the following command:
*
* [docs-import]: https://developer.hashicorp.com/terraform/cli/import
*
* ```sh
* $ pulumi import vsphere:index/folder:Folder folder /default-dc/vm/example-vm-folder
* ```
*
* The above command would import the folder from our examples above, the VM
*
* folder named `example-vm-folder` located in the datacenter named
*
* `default-dc`.
*/
class Folder extends pulumi.CustomResource {
/**
* Get an existing Folder 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 Folder(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of Folder. 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'] === Folder.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["customAttributes"] = state ? state.customAttributes : undefined;
resourceInputs["datacenterId"] = state ? state.datacenterId : undefined;
resourceInputs["path"] = state ? state.path : undefined;
resourceInputs["tags"] = state ? state.tags : undefined;
resourceInputs["type"] = state ? state.type : undefined;
}
else {
const args = argsOrState;
if ((!args || args.path === undefined) && !opts.urn) {
throw new Error("Missing required property 'path'");
}
if ((!args || args.type === undefined) && !opts.urn) {
throw new Error("Missing required property 'type'");
}
resourceInputs["customAttributes"] = args ? args.customAttributes : undefined;
resourceInputs["datacenterId"] = args ? args.datacenterId : undefined;
resourceInputs["path"] = args ? args.path : undefined;
resourceInputs["tags"] = args ? args.tags : undefined;
resourceInputs["type"] = args ? args.type : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Folder.__pulumiType, name, resourceInputs, opts);
}
}
exports.Folder = Folder;
/** @internal */
Folder.__pulumiType = 'vsphere:index/folder:Folder';
//# sourceMappingURL=folder.js.map