@natzka-oss/pulumi-netbox
Version:
A Pulumi package for creating and managing Netbox cloud resources.
143 lines • 8 kB
JavaScript
;
// *** 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.Device = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* From the [official documentation](https://docs.netbox.dev/en/stable/features/devices/#devices):
*
* > Every piece of hardware which is installed within a site or rack exists in NetBox as a device. Devices are measured in rack units (U) and can be half depth or full depth. A device may have a height of 0U: These devices do not consume vertical rack space and cannot be assigned to a particular rack unit. A common example of a 0U device is a vertically-mounted PDU.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as netbox from "@natzka-oss/pulumi-netbox";
*
* const test = new netbox.dcim.Site("test", {name: "%[1]s"});
* const testDeviceRole = new netbox.dcim.DeviceRole("test", {
* name: "%[1]s",
* colorHex: "123456",
* });
* const testManufacturer = new netbox.dcim.Manufacturer("test", {name: "test"});
* const testDeviceType = new netbox.dcim.DeviceType("test", {
* model: "test",
* manufacturerId: testManufacturer.id,
* });
* const testDevice = new netbox.dcim.Device("test", {
* name: "%[1]s",
* deviceTypeId: testDeviceType.id,
* roleId: testDeviceRole.id,
* siteId: test.id,
* localContextData: JSON.stringify({
* setting_a: "Some Setting",
* setting_b: 42,
* }),
* });
* ```
*/
class Device extends pulumi.CustomResource {
/**
* Get an existing Device 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 Device(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of Device. 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'] === Device.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["assetTag"] = state ? state.assetTag : undefined;
resourceInputs["clusterId"] = state ? state.clusterId : undefined;
resourceInputs["comments"] = state ? state.comments : undefined;
resourceInputs["configTemplateId"] = state ? state.configTemplateId : undefined;
resourceInputs["customFields"] = state ? state.customFields : undefined;
resourceInputs["description"] = state ? state.description : undefined;
resourceInputs["deviceTypeId"] = state ? state.deviceTypeId : undefined;
resourceInputs["localContextData"] = state ? state.localContextData : undefined;
resourceInputs["locationId"] = state ? state.locationId : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["platformId"] = state ? state.platformId : undefined;
resourceInputs["primaryIpv4"] = state ? state.primaryIpv4 : undefined;
resourceInputs["primaryIpv6"] = state ? state.primaryIpv6 : undefined;
resourceInputs["rackFace"] = state ? state.rackFace : undefined;
resourceInputs["rackId"] = state ? state.rackId : undefined;
resourceInputs["rackPosition"] = state ? state.rackPosition : undefined;
resourceInputs["roleId"] = state ? state.roleId : undefined;
resourceInputs["serial"] = state ? state.serial : undefined;
resourceInputs["siteId"] = state ? state.siteId : undefined;
resourceInputs["status"] = state ? state.status : undefined;
resourceInputs["tags"] = state ? state.tags : undefined;
resourceInputs["tagsAlls"] = state ? state.tagsAlls : undefined;
resourceInputs["tenantId"] = state ? state.tenantId : undefined;
resourceInputs["virtualChassisId"] = state ? state.virtualChassisId : undefined;
resourceInputs["virtualChassisMaster"] = state ? state.virtualChassisMaster : undefined;
resourceInputs["virtualChassisPosition"] = state ? state.virtualChassisPosition : undefined;
resourceInputs["virtualChassisPriority"] = state ? state.virtualChassisPriority : undefined;
}
else {
const args = argsOrState;
if ((!args || args.deviceTypeId === undefined) && !opts.urn) {
throw new Error("Missing required property 'deviceTypeId'");
}
if ((!args || args.roleId === undefined) && !opts.urn) {
throw new Error("Missing required property 'roleId'");
}
if ((!args || args.siteId === undefined) && !opts.urn) {
throw new Error("Missing required property 'siteId'");
}
resourceInputs["assetTag"] = args ? args.assetTag : undefined;
resourceInputs["clusterId"] = args ? args.clusterId : undefined;
resourceInputs["comments"] = args ? args.comments : undefined;
resourceInputs["configTemplateId"] = args ? args.configTemplateId : undefined;
resourceInputs["customFields"] = args ? args.customFields : undefined;
resourceInputs["description"] = args ? args.description : undefined;
resourceInputs["deviceTypeId"] = args ? args.deviceTypeId : undefined;
resourceInputs["localContextData"] = args ? args.localContextData : undefined;
resourceInputs["locationId"] = args ? args.locationId : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["platformId"] = args ? args.platformId : undefined;
resourceInputs["rackFace"] = args ? args.rackFace : undefined;
resourceInputs["rackId"] = args ? args.rackId : undefined;
resourceInputs["rackPosition"] = args ? args.rackPosition : undefined;
resourceInputs["roleId"] = args ? args.roleId : undefined;
resourceInputs["serial"] = args ? args.serial : undefined;
resourceInputs["siteId"] = args ? args.siteId : undefined;
resourceInputs["status"] = args ? args.status : undefined;
resourceInputs["tags"] = args ? args.tags : undefined;
resourceInputs["tenantId"] = args ? args.tenantId : undefined;
resourceInputs["virtualChassisId"] = args ? args.virtualChassisId : undefined;
resourceInputs["virtualChassisMaster"] = args ? args.virtualChassisMaster : undefined;
resourceInputs["virtualChassisPosition"] = args ? args.virtualChassisPosition : undefined;
resourceInputs["virtualChassisPriority"] = args ? args.virtualChassisPriority : undefined;
resourceInputs["primaryIpv4"] = undefined /*out*/;
resourceInputs["primaryIpv6"] = undefined /*out*/;
resourceInputs["tagsAlls"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Device.__pulumiType, name, resourceInputs, opts);
}
}
exports.Device = Device;
/** @internal */
Device.__pulumiType = 'netbox:dcim/device:Device';
//# sourceMappingURL=device.js.map