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

netbox.InventoryItemRole

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 can be organized by functional roles, which are fully customizable by the user. For example, you might create roles for power supplies, fans, interface optics, etc.

    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 testInventoryItemRole = new netbox.InventoryItemRole("testInventoryItemRole", {
        slug: "role-1-slug",
        colorHex: "123456",
    });
    const parent = new netbox.InventoryItem("parent", {
        deviceId: testDevice.deviceId,
        roleId: testInventoryItemRole.inventoryItemRoleId,
    });
    
    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_inventory_item_role = netbox.InventoryItemRole("testInventoryItemRole",
        slug="role-1-slug",
        color_hex="123456")
    parent = netbox.InventoryItem("parent",
        device_id=test_device.device_id,
        role_id=test_inventory_item_role.inventory_item_role_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
    		}
    		testInventoryItemRole, err := netbox.NewInventoryItemRole(ctx, "testInventoryItemRole", &netbox.InventoryItemRoleArgs{
    			Slug:     pulumi.String("role-1-slug"),
    			ColorHex: pulumi.String("123456"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = netbox.NewInventoryItem(ctx, "parent", &netbox.InventoryItemArgs{
    			DeviceId: testDevice.DeviceId,
    			RoleId:   testInventoryItemRole.InventoryItemRoleId,
    		})
    		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 testInventoryItemRole = new Netbox.InventoryItemRole("testInventoryItemRole", new()
        {
            Slug = "role-1-slug",
            ColorHex = "123456",
        });
    
        var parent = new Netbox.InventoryItem("parent", new()
        {
            DeviceId = testDevice.DeviceId,
            RoleId = testInventoryItemRole.InventoryItemRoleId,
        });
    
    });
    
    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.InventoryItemRole;
    import com.pulumi.netbox.InventoryItemRoleArgs;
    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 testInventoryItemRole = new InventoryItemRole("testInventoryItemRole", InventoryItemRoleArgs.builder()
                .slug("role-1-slug")
                .colorHex("123456")
                .build());
    
            var parent = new InventoryItem("parent", InventoryItemArgs.builder()
                .deviceId(testDevice.deviceId())
                .roleId(testInventoryItemRole.inventoryItemRoleId())
                .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}
      testInventoryItemRole:
        type: netbox:InventoryItemRole
        properties:
          slug: role-1-slug
          colorHex: '123456'
      parent:
        type: netbox:InventoryItem
        properties:
          deviceId: ${testDevice.deviceId}
          roleId: ${testInventoryItemRole.inventoryItemRoleId}
    

    Create InventoryItemRole Resource

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

    Constructor syntax

    new InventoryItemRole(name: string, args: InventoryItemRoleArgs, opts?: CustomResourceOptions);
    @overload
    def InventoryItemRole(resource_name: str,
                          args: InventoryItemRoleArgs,
                          opts: Optional[ResourceOptions] = None)
    
    @overload
    def InventoryItemRole(resource_name: str,
                          opts: Optional[ResourceOptions] = None,
                          color_hex: Optional[str] = None,
                          slug: Optional[str] = None,
                          custom_fields: Optional[Mapping[str, str]] = None,
                          description: Optional[str] = None,
                          inventory_item_role_id: Optional[str] = None,
                          name: Optional[str] = None,
                          tags: Optional[Sequence[str]] = None)
    func NewInventoryItemRole(ctx *Context, name string, args InventoryItemRoleArgs, opts ...ResourceOption) (*InventoryItemRole, error)
    public InventoryItemRole(string name, InventoryItemRoleArgs args, CustomResourceOptions? opts = null)
    public InventoryItemRole(String name, InventoryItemRoleArgs args)
    public InventoryItemRole(String name, InventoryItemRoleArgs args, CustomResourceOptions options)
    
    type: netbox:InventoryItemRole
    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 InventoryItemRoleArgs
    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 InventoryItemRoleArgs
    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 InventoryItemRoleArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args InventoryItemRoleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args InventoryItemRoleArgs
    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 inventoryItemRoleResource = new Netbox.InventoryItemRole("inventoryItemRoleResource", new()
    {
        ColorHex = "string",
        Slug = "string",
        CustomFields = 
        {
            { "string", "string" },
        },
        Description = "string",
        InventoryItemRoleId = "string",
        Name = "string",
        Tags = new[]
        {
            "string",
        },
    });
    
    example, err := netbox.NewInventoryItemRole(ctx, "inventoryItemRoleResource", &netbox.InventoryItemRoleArgs{
    	ColorHex: pulumi.String("string"),
    	Slug:     pulumi.String("string"),
    	CustomFields: pulumi.StringMap{
    		"string": pulumi.String("string"),
    	},
    	Description:         pulumi.String("string"),
    	InventoryItemRoleId: pulumi.String("string"),
    	Name:                pulumi.String("string"),
    	Tags: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    })
    
    var inventoryItemRoleResource = new InventoryItemRole("inventoryItemRoleResource", InventoryItemRoleArgs.builder()
        .colorHex("string")
        .slug("string")
        .customFields(Map.of("string", "string"))
        .description("string")
        .inventoryItemRoleId("string")
        .name("string")
        .tags("string")
        .build());
    
    inventory_item_role_resource = netbox.InventoryItemRole("inventoryItemRoleResource",
        color_hex="string",
        slug="string",
        custom_fields={
            "string": "string",
        },
        description="string",
        inventory_item_role_id="string",
        name="string",
        tags=["string"])
    
    const inventoryItemRoleResource = new netbox.InventoryItemRole("inventoryItemRoleResource", {
        colorHex: "string",
        slug: "string",
        customFields: {
            string: "string",
        },
        description: "string",
        inventoryItemRoleId: "string",
        name: "string",
        tags: ["string"],
    });
    
    type: netbox:InventoryItemRole
    properties:
        colorHex: string
        customFields:
            string: string
        description: string
        inventoryItemRoleId: string
        name: string
        slug: string
        tags:
            - string
    

    InventoryItemRole 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 InventoryItemRole resource accepts the following input properties:

    ColorHex string
    Slug string
    CustomFields Dictionary<string, string>
    Description string
    InventoryItemRoleId string
    The ID of this resource.
    Name string
    Tags List<string>
    ColorHex string
    Slug string
    CustomFields map[string]string
    Description string
    InventoryItemRoleId string
    The ID of this resource.
    Name string
    Tags []string
    colorHex String
    slug String
    customFields Map<String,String>
    description String
    inventoryItemRoleId String
    The ID of this resource.
    name String
    tags List<String>
    colorHex string
    slug string
    customFields {[key: string]: string}
    description string
    inventoryItemRoleId string
    The ID of this resource.
    name string
    tags string[]
    color_hex str
    slug str
    custom_fields Mapping[str, str]
    description str
    inventory_item_role_id str
    The ID of this resource.
    name str
    tags Sequence[str]
    colorHex String
    slug String
    customFields Map<String>
    description String
    inventoryItemRoleId String
    The ID of this resource.
    name String
    tags List<String>

    Outputs

    All input properties are implicitly available as output properties. Additionally, the InventoryItemRole 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 InventoryItemRole Resource

    Get an existing InventoryItemRole 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?: InventoryItemRoleState, opts?: CustomResourceOptions): InventoryItemRole
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            color_hex: Optional[str] = None,
            custom_fields: Optional[Mapping[str, str]] = None,
            description: Optional[str] = None,
            inventory_item_role_id: Optional[str] = None,
            name: Optional[str] = None,
            slug: Optional[str] = None,
            tags: Optional[Sequence[str]] = None) -> InventoryItemRole
    func GetInventoryItemRole(ctx *Context, name string, id IDInput, state *InventoryItemRoleState, opts ...ResourceOption) (*InventoryItemRole, error)
    public static InventoryItemRole Get(string name, Input<string> id, InventoryItemRoleState? state, CustomResourceOptions? opts = null)
    public static InventoryItemRole get(String name, Output<String> id, InventoryItemRoleState state, CustomResourceOptions options)
    resources:  _:    type: netbox:InventoryItemRole    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:
    ColorHex string
    CustomFields Dictionary<string, string>
    Description string
    InventoryItemRoleId string
    The ID of this resource.
    Name string
    Slug string
    Tags List<string>
    ColorHex string
    CustomFields map[string]string
    Description string
    InventoryItemRoleId string
    The ID of this resource.
    Name string
    Slug string
    Tags []string
    colorHex String
    customFields Map<String,String>
    description String
    inventoryItemRoleId String
    The ID of this resource.
    name String
    slug String
    tags List<String>
    colorHex string
    customFields {[key: string]: string}
    description string
    inventoryItemRoleId string
    The ID of this resource.
    name string
    slug string
    tags string[]
    color_hex str
    custom_fields Mapping[str, str]
    description str
    inventory_item_role_id str
    The ID of this resource.
    name str
    slug str
    tags Sequence[str]
    colorHex String
    customFields Map<String>
    description String
    inventoryItemRoleId String
    The ID of this resource.
    name String
    slug 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