UNPKG

@natzka-oss/pulumi-netbox

Version:

A Pulumi package for creating and managing Netbox cloud resources.

160 lines 6.75 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.MacAddress = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * From the [official documentation](https://netboxlabs.com/docs/netbox/models/dcim/macaddress/): * * > A MAC address object in NetBox comprises a single Ethernet link layer address, and represents a MAC address as reported by or assigned to a network interface. MAC addresses can be assigned to device and virtual machine interfaces. A MAC address can be specified as the primary MAC address for a given device or VM interface. * * ## Example Usage * * ### Creating a MAC address that is assigned to a virtual machine interface * * With `virtualMachineInterfaceId`: * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as netbox from "@natzka-oss/pulumi-netbox"; * * // Assuming a virtual machine with the id `123` exists * const _this = new netbox.virt.Interface("this", { * name: "eth0", * virtualMachineId: 123, * }); * const thisMacAddress = new netbox.MacAddress("this", { * macAddress: "00:1A:2B:3C:4D:5E", * virtualMachineInterfaceId: _this.id, * }); * ``` * * With `objectType` and `interfaceId`: * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as netbox from "@natzka-oss/pulumi-netbox"; * * // Assuming a virtual machine with the id `123` exists * const _this = new netbox.virt.Interface("this", { * name: "eth0", * virtualMachineId: 123, * }); * const thisMacAddress = new netbox.MacAddress("this", { * macAddress: "00:1A:2B:3C:4D:5E", * interfaceId: _this.id, * objectType: "virtualization.vminterface", * }); * ``` * * ### Creating a MAC address that is assigned to a device interface * * With `deviceInterfaceId`: * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as netbox from "@natzka-oss/pulumi-netbox"; * * // Assuming a device with the id `123` exists * const _this = new netbox.dcim.DeviceInterface("this", { * name: "eth0", * deviceId: 123, * type: "1000base-t", * }); * const thisMacAddress = new netbox.MacAddress("this", { * macAddress: "00:1A:2B:3C:4D:5E", * deviceInterfaceId: _this.id, * }); * ``` * * With `objectType` and `interfaceId`: * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as netbox from "@natzka-oss/pulumi-netbox"; * * // Assuming a device with the id `123` exists * const _this = new netbox.dcim.DeviceInterface("this", { * name: "eth0", * deviceId: 123, * type: "1000base-t", * }); * const thisMacAddress = new netbox.MacAddress("this", { * macAddress: "00:1A:2B:3C:4D:5E", * interfaceId: _this.id, * objectType: "dcim.interface", * }); * ``` * * ### Creating a MAC address that is not assigned to anything * * You can create a MAC address that is not assigned to anything by omitting the attributes mentioned above. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as netbox from "@natzka-oss/pulumi-netbox"; * * const _this = new netbox.MacAddress("this", {macAddress: "00:1A:2B:3C:4D:5E"}); * ``` */ class MacAddress extends pulumi.CustomResource { /** * Get an existing MacAddress 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 MacAddress(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of MacAddress. 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'] === MacAddress.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["comments"] = state ? state.comments : undefined; resourceInputs["customFields"] = state ? state.customFields : undefined; resourceInputs["description"] = state ? state.description : undefined; resourceInputs["deviceInterfaceId"] = state ? state.deviceInterfaceId : undefined; resourceInputs["interfaceId"] = state ? state.interfaceId : undefined; resourceInputs["macAddress"] = state ? state.macAddress : undefined; resourceInputs["objectType"] = state ? state.objectType : undefined; resourceInputs["tags"] = state ? state.tags : undefined; resourceInputs["tagsAlls"] = state ? state.tagsAlls : undefined; resourceInputs["virtualMachineInterfaceId"] = state ? state.virtualMachineInterfaceId : undefined; } else { const args = argsOrState; if ((!args || args.macAddress === undefined) && !opts.urn) { throw new Error("Missing required property 'macAddress'"); } resourceInputs["comments"] = args ? args.comments : undefined; resourceInputs["customFields"] = args ? args.customFields : undefined; resourceInputs["description"] = args ? args.description : undefined; resourceInputs["deviceInterfaceId"] = args ? args.deviceInterfaceId : undefined; resourceInputs["interfaceId"] = args ? args.interfaceId : undefined; resourceInputs["macAddress"] = args ? args.macAddress : undefined; resourceInputs["objectType"] = args ? args.objectType : undefined; resourceInputs["tags"] = args ? args.tags : undefined; resourceInputs["virtualMachineInterfaceId"] = args ? args.virtualMachineInterfaceId : undefined; resourceInputs["tagsAlls"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(MacAddress.__pulumiType, name, resourceInputs, opts); } } exports.MacAddress = MacAddress; /** @internal */ MacAddress.__pulumiType = 'netbox:index/macAddress:MacAddress'; //# sourceMappingURL=macAddress.js.map