1. Packages
  2. Netbox Provider
  3. API Docs
  4. InventoryItem
netbox 3.10.0 published on Monday, Apr 14, 2025 by e-breuninger

netbox.InventoryItem

Explore with Pulumi AI

netbox logo
netbox 3.10.0 published on Monday, Apr 14, 2025 by e-breuninger

    From the official documentation:

    Inventory items represent hardware components installed within a device, such as a power supply or CPU or line card. They are intended to be used primarily for inventory purposes.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as netbox from "@pulumi/netbox";
    
    // Note that some terraform code is not included in the example for brevity
    const testDevice = new netbox.Device("testDevice", {
        deviceTypeId: netbox_device_type.test.id,
        tenantId: netbox_tenant.test.id,
        roleId: netbox_device_role.test.id,
        siteId: netbox_site.test.id,
    });
    const testDeviceRearPort = new netbox.DeviceRearPort("testDeviceRearPort", {
        deviceId: testDevice.deviceId,
        type: "8p8c",
        positions: 1,
        markConnected: true,
    });
    const parent = new netbox.InventoryItem("parent", {deviceId: testDevice.deviceId});
    const testInventoryItem = new netbox.InventoryItem("testInventoryItem", {
        deviceId: testDevice.deviceId,
        parentId: parent.inventoryItemId,
        componentType: "dcim.rearport",
        componentId: testDeviceRearPort.deviceRearPortId,
    });
    
    import pulumi
    import pulumi_netbox as netbox
    
    # Note that some terraform code is not included in the example for brevity
    test_device = netbox.Device("testDevice",
        device_type_id=netbox_device_type["test"]["id"],
        tenant_id=netbox_tenant["test"]["id"],
        role_id=netbox_device_role["test"]["id"],
        site_id=netbox_site["test"]["id"])
    test_device_rear_port = netbox.DeviceRearPort("testDeviceRearPort",
        device_id=test_device.device_id,
        type="8p8c",
        positions=1,
        mark_connected=True)
    parent = netbox.InventoryItem("parent", device_id=test_device.device_id)
    test_inventory_item = netbox.InventoryItem("testInventoryItem",
        device_id=test_device.device_id,
        parent_id=parent.inventory_item_id,
        component_type="dcim.rearport",
        component_id=test_device_rear_port.device_rear_port_id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/netbox/v3/netbox"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// Note that some terraform code is not included in the example for brevity
    		testDevice, err := netbox.NewDevice(ctx, "testDevice", &netbox.DeviceArgs{
    			DeviceTypeId: pulumi.Any(netbox_device_type.Test.Id),
    			TenantId:     pulumi.Any(netbox_tenant.Test.Id),
    			RoleId:       pulumi.Any(netbox_device_role.Test.Id),
    			SiteId:       pulumi.Any(netbox_site.Test.Id),
    		})
    		if err != nil {
    			return err
    		}
    		testDeviceRearPort, err := netbox.NewDeviceRearPort(ctx, "testDeviceRearPort", &netbox.DeviceRearPortArgs{
    			DeviceId:      testDevice.DeviceId,
    			Type:          pulumi.String("8p8c"),
    			Positions:     pulumi.Float64(1),
    			MarkConnected: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		parent, err := netbox.NewInventoryItem(ctx, "parent", &netbox.InventoryItemArgs{
    			DeviceId: testDevice.DeviceId,
    		})
    		if err != nil {
    			return err
    		}
    		_, err = netbox.NewInventoryItem(ctx, "testInventoryItem", &netbox.InventoryItemArgs{
    			DeviceId:      testDevice.DeviceId,
    			ParentId:      parent.InventoryItemId,
    			ComponentType: pulumi.String("dcim.rearport"),
    			ComponentId:   testDeviceRearPort.DeviceRearPortId,
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Netbox = Pulumi.Netbox;
    
    return await Deployment.RunAsync(() => 
    {
        // Note that some terraform code is not included in the example for brevity
        var testDevice = new Netbox.Device("testDevice", new()
        {
            DeviceTypeId = netbox_device_type.Test.Id,
            TenantId = netbox_tenant.Test.Id,
            RoleId = netbox_device_role.Test.Id,
            SiteId = netbox_site.Test.Id,
        });
    
        var testDeviceRearPort = new Netbox.DeviceRearPort("testDeviceRearPort", new()
        {
            DeviceId = testDevice.DeviceId,
            Type = "8p8c",
            Positions = 1,
            MarkConnected = true,
        });
    
        var parent = new Netbox.InventoryItem("parent", new()
        {
            DeviceId = testDevice.DeviceId,
        });
    
        var testInventoryItem = new Netbox.InventoryItem("testInventoryItem", new()
        {
            DeviceId = testDevice.DeviceId,
            ParentId = parent.InventoryItemId,
            ComponentType = "dcim.rearport",
            ComponentId = testDeviceRearPort.DeviceRearPortId,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.netbox.Device;
    import com.pulumi.netbox.DeviceArgs;
    import com.pulumi.netbox.DeviceRearPort;
    import com.pulumi.netbox.DeviceRearPortArgs;
    import com.pulumi.netbox.InventoryItem;
    import com.pulumi.netbox.InventoryItemArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            // Note that some terraform code is not included in the example for brevity
            var testDevice = new Device("testDevice", DeviceArgs.builder()
                .deviceTypeId(netbox_device_type.test().id())
                .tenantId(netbox_tenant.test().id())
                .roleId(netbox_device_role.test().id())
                .siteId(netbox_site.test().id())
                .build());
    
            var testDeviceRearPort = new DeviceRearPort("testDeviceRearPort", DeviceRearPortArgs.builder()
                .deviceId(testDevice.deviceId())
                .type("8p8c")
                .positions(1)
                .markConnected(true)
                .build());
    
            var parent = new InventoryItem("parent", InventoryItemArgs.builder()
                .deviceId(testDevice.deviceId())
                .build());
    
            var testInventoryItem = new InventoryItem("testInventoryItem", InventoryItemArgs.builder()
                .deviceId(testDevice.deviceId())
                .parentId(parent.inventoryItemId())
                .componentType("dcim.rearport")
                .componentId(testDeviceRearPort.deviceRearPortId())
                .build());
    
        }
    }
    
    resources:
      # Note that some terraform code is not included in the example for brevity
      testDevice:
        type: netbox:Device
        properties:
          deviceTypeId: ${netbox_device_type.test.id}
          tenantId: ${netbox_tenant.test.id}
          roleId: ${netbox_device_role.test.id}
          siteId: ${netbox_site.test.id}
      testDeviceRearPort:
        type: netbox:DeviceRearPort
        properties:
          deviceId: ${testDevice.deviceId}
          type: 8p8c
          positions: 1
          markConnected: true
      parent:
        type: netbox:InventoryItem
        properties:
          deviceId: ${testDevice.deviceId}
      testInventoryItem:
        type: netbox:InventoryItem
        properties:
          deviceId: ${testDevice.deviceId}
          parentId: ${parent.inventoryItemId}
          componentType: dcim.rearport
          componentId: ${testDeviceRearPort.deviceRearPortId}
    

    Create InventoryItem Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new InventoryItem(name: string, args: InventoryItemArgs, opts?: CustomResourceOptions);
    @overload
    def InventoryItem(resource_name: str,
                      args: InventoryItemArgs,
                      opts: Optional[ResourceOptions] = None)
    
    @overload
    def InventoryItem(resource_name: str,
                      opts: Optional[ResourceOptions] = None,
                      device_id: Optional[float] = None,
                      label: Optional[str] = None,
                      parent_id: Optional[float] = None,
                      custom_fields: Optional[Mapping[str, str]] = None,
                      description: Optional[str] = None,
                      component_id: Optional[float] = None,
                      discovered: Optional[bool] = None,
                      component_type: Optional[str] = None,
                      manufacturer_id: Optional[float] = None,
                      inventory_item_id: Optional[str] = None,
                      name: Optional[str] = None,
                      asset_tag: Optional[str] = None,
                      part_id: Optional[str] = None,
                      role_id: Optional[float] = None,
                      serial: Optional[str] = None,
                      tags: Optional[Sequence[str]] = None)
    func NewInventoryItem(ctx *Context, name string, args InventoryItemArgs, opts ...ResourceOption) (*InventoryItem, error)
    public InventoryItem(string name, InventoryItemArgs args, CustomResourceOptions? opts = null)
    public InventoryItem(String name, InventoryItemArgs args)
    public InventoryItem(String name, InventoryItemArgs args, CustomResourceOptions options)
    
    type: netbox:InventoryItem
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args InventoryItemArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args InventoryItemArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args InventoryItemArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args InventoryItemArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args InventoryItemArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var inventoryItemResource = new Netbox.InventoryItem("inventoryItemResource", new()
    {
        DeviceId = 0,
        Label = "string",
        ParentId = 0,
        CustomFields = 
        {
            { "string", "string" },
        },
        Description = "string",
        ComponentId = 0,
        Discovered = false,
        ComponentType = "string",
        ManufacturerId = 0,
        InventoryItemId = "string",
        Name = "string",
        AssetTag = "string",
        PartId = "string",
        RoleId = 0,
        Serial = "string",
        Tags = new[]
        {
            "string",
        },
    });
    
    example, err := netbox.NewInventoryItem(ctx, "inventoryItemResource", &netbox.InventoryItemArgs{
    	DeviceId: pulumi.Float64(0),
    	Label:    pulumi.String("string"),
    	ParentId: pulumi.Float64(0),
    	CustomFields: pulumi.StringMap{
    		"string": pulumi.String("string"),
    	},
    	Description:     pulumi.String("string"),
    	ComponentId:     pulumi.Float64(0),
    	Discovered:      pulumi.Bool(false),
    	ComponentType:   pulumi.String("string"),
    	ManufacturerId:  pulumi.Float64(0),
    	InventoryItemId: pulumi.String("string"),
    	Name:            pulumi.String("string"),
    	AssetTag:        pulumi.String("string"),
    	PartId:          pulumi.String("string"),
    	RoleId:          pulumi.Float64(0),
    	Serial:          pulumi.String("string"),
    	Tags: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    })
    
    var inventoryItemResource = new InventoryItem("inventoryItemResource", InventoryItemArgs.builder()
        .deviceId(0)
        .label("string")
        .parentId(0)
        .customFields(Map.of("string", "string"))
        .description("string")
        .componentId(0)
        .discovered(false)
        .componentType("string")
        .manufacturerId(0)
        .inventoryItemId("string")
        .name("string")
        .assetTag("string")
        .partId("string")
        .roleId(0)
        .serial("string")
        .tags("string")
        .build());
    
    inventory_item_resource = netbox.InventoryItem("inventoryItemResource",
        device_id=0,
        label="string",
        parent_id=0,
        custom_fields={
            "string": "string",
        },
        description="string",
        component_id=0,
        discovered=False,
        component_type="string",
        manufacturer_id=0,
        inventory_item_id="string",
        name="string",
        asset_tag="string",
        part_id="string",
        role_id=0,
        serial="string",
        tags=["string"])
    
    const inventoryItemResource = new netbox.InventoryItem("inventoryItemResource", {
        deviceId: 0,
        label: "string",
        parentId: 0,
        customFields: {
            string: "string",
        },
        description: "string",
        componentId: 0,
        discovered: false,
        componentType: "string",
        manufacturerId: 0,
        inventoryItemId: "string",
        name: "string",
        assetTag: "string",
        partId: "string",
        roleId: 0,
        serial: "string",
        tags: ["string"],
    });
    
    type: netbox:InventoryItem
    properties:
        assetTag: string
        componentId: 0
        componentType: string
        customFields:
            string: string
        description: string
        deviceId: 0
        discovered: false
        inventoryItemId: string
        label: string
        manufacturerId: 0
        name: string
        parentId: 0
        partId: string
        roleId: 0
        serial: string
        tags:
            - string
    

    InventoryItem Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The InventoryItem resource accepts the following input properties:

    DeviceId double
    AssetTag string
    ComponentId double
    Required when component_type is set.
    ComponentType string
    CustomFields Dictionary<string, string>
    Description string
    Discovered bool
    Defaults to false.
    InventoryItemId string
    The ID of this resource.
    Label string
    ManufacturerId double
    Name string
    ParentId double
    PartId string
    RoleId double
    Serial string
    Tags List<string>
    DeviceId float64
    AssetTag string
    ComponentId float64
    Required when component_type is set.
    ComponentType string
    CustomFields map[string]string
    Description string
    Discovered bool
    Defaults to false.
    InventoryItemId string
    The ID of this resource.
    Label string
    ManufacturerId float64
    Name string
    ParentId float64
    PartId string
    RoleId float64
    Serial string
    Tags []string
    deviceId Double
    assetTag String
    componentId Double
    Required when component_type is set.
    componentType String
    customFields Map<String,String>
    description String
    discovered Boolean
    Defaults to false.
    inventoryItemId String
    The ID of this resource.
    label String
    manufacturerId Double
    name String
    parentId Double
    partId String
    roleId Double
    serial String
    tags List<String>
    deviceId number
    assetTag string
    componentId number
    Required when component_type is set.
    componentType string
    customFields {[key: string]: string}
    description string
    discovered boolean
    Defaults to false.
    inventoryItemId string
    The ID of this resource.
    label string
    manufacturerId number
    name string
    parentId number
    partId string
    roleId number
    serial string
    tags string[]
    device_id float
    asset_tag str
    component_id float
    Required when component_type is set.
    component_type str
    custom_fields Mapping[str, str]
    description str
    discovered bool
    Defaults to false.
    inventory_item_id str
    The ID of this resource.
    label str
    manufacturer_id float
    name str
    parent_id float
    part_id str
    role_id float
    serial str
    tags Sequence[str]
    deviceId Number
    assetTag String
    componentId Number
    Required when component_type is set.
    componentType String
    customFields Map<String>
    description String
    discovered Boolean
    Defaults to false.
    inventoryItemId String
    The ID of this resource.
    label String
    manufacturerId Number
    name String
    parentId Number
    partId String
    roleId Number
    serial String
    tags List<String>

    Outputs

    All input properties are implicitly available as output properties. Additionally, the InventoryItem resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing InventoryItem Resource

    Get an existing InventoryItem resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: InventoryItemState, opts?: CustomResourceOptions): InventoryItem
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            asset_tag: Optional[str] = None,
            component_id: Optional[float] = None,
            component_type: Optional[str] = None,
            custom_fields: Optional[Mapping[str, str]] = None,
            description: Optional[str] = None,
            device_id: Optional[float] = None,
            discovered: Optional[bool] = None,
            inventory_item_id: Optional[str] = None,
            label: Optional[str] = None,
            manufacturer_id: Optional[float] = None,
            name: Optional[str] = None,
            parent_id: Optional[float] = None,
            part_id: Optional[str] = None,
            role_id: Optional[float] = None,
            serial: Optional[str] = None,
            tags: Optional[Sequence[str]] = None) -> InventoryItem
    func GetInventoryItem(ctx *Context, name string, id IDInput, state *InventoryItemState, opts ...ResourceOption) (*InventoryItem, error)
    public static InventoryItem Get(string name, Input<string> id, InventoryItemState? state, CustomResourceOptions? opts = null)
    public static InventoryItem get(String name, Output<String> id, InventoryItemState state, CustomResourceOptions options)
    resources:  _:    type: netbox:InventoryItem    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    AssetTag string
    ComponentId double
    Required when component_type is set.
    ComponentType string
    CustomFields Dictionary<string, string>
    Description string
    DeviceId double
    Discovered bool
    Defaults to false.
    InventoryItemId string
    The ID of this resource.
    Label string
    ManufacturerId double
    Name string
    ParentId double
    PartId string
    RoleId double
    Serial string
    Tags List<string>
    AssetTag string
    ComponentId float64
    Required when component_type is set.
    ComponentType string
    CustomFields map[string]string
    Description string
    DeviceId float64
    Discovered bool
    Defaults to false.
    InventoryItemId string
    The ID of this resource.
    Label string
    ManufacturerId float64
    Name string
    ParentId float64
    PartId string
    RoleId float64
    Serial string
    Tags []string
    assetTag String
    componentId Double
    Required when component_type is set.
    componentType String
    customFields Map<String,String>
    description String
    deviceId Double
    discovered Boolean
    Defaults to false.
    inventoryItemId String
    The ID of this resource.
    label String
    manufacturerId Double
    name String
    parentId Double
    partId String
    roleId Double
    serial String
    tags List<String>
    assetTag string
    componentId number
    Required when component_type is set.
    componentType string
    customFields {[key: string]: string}
    description string
    deviceId number
    discovered boolean
    Defaults to false.
    inventoryItemId string
    The ID of this resource.
    label string
    manufacturerId number
    name string
    parentId number
    partId string
    roleId number
    serial string
    tags string[]
    asset_tag str
    component_id float
    Required when component_type is set.
    component_type str
    custom_fields Mapping[str, str]
    description str
    device_id float
    discovered bool
    Defaults to false.
    inventory_item_id str
    The ID of this resource.
    label str
    manufacturer_id float
    name str
    parent_id float
    part_id str
    role_id float
    serial str
    tags Sequence[str]
    assetTag String
    componentId Number
    Required when component_type is set.
    componentType String
    customFields Map<String>
    description String
    deviceId Number
    discovered Boolean
    Defaults to false.
    inventoryItemId String
    The ID of this resource.
    label String
    manufacturerId Number
    name String
    parentId Number
    partId String
    roleId Number
    serial String
    tags List<String>

    Package Details

    Repository
    netbox e-breuninger/terraform-provider-netbox
    License
    Notes
    This Pulumi package is based on the netbox Terraform Provider.
    netbox logo
    netbox 3.10.0 published on Monday, Apr 14, 2025 by e-breuninger