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

netbox.CustomField

Explore with Pulumi AI

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

    From the official documentation:

    Each model in NetBox is represented in the database as a discrete table, and each attribute of a model exists as a column within its table. For example, sites are stored in the dcim_site table, which has columns named name, facility, physical_address, and so on. As new attributes are added to objects throughout the development of NetBox, tables are expanded to include new rows.

    However, some users might want to store additional object attributes that are somewhat esoteric in nature, and that would not make sense to include in the core NetBox database schema. For instance, suppose your organization needs to associate each device with a ticket number correlating it with an internal support system record. This is certainly a legitimate use for NetBox, but it’s not a common enough need to warrant including a field for every NetBox installation. Instead, you can create a custom field to hold this data.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as netbox from "@pulumi/netbox";
    
    const test = new netbox.CustomField("test", {
        contentTypes: ["virtualization.vminterface"],
        type: "text",
        validationRegex: "^.*$",
        weight: 100,
    });
    
    import pulumi
    import pulumi_netbox as netbox
    
    test = netbox.CustomField("test",
        content_types=["virtualization.vminterface"],
        type="text",
        validation_regex="^.*$",
        weight=100)
    
    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 {
    		_, err := netbox.NewCustomField(ctx, "test", &netbox.CustomFieldArgs{
    			ContentTypes: pulumi.StringArray{
    				pulumi.String("virtualization.vminterface"),
    			},
    			Type:            pulumi.String("text"),
    			ValidationRegex: pulumi.String("^.*$"),
    			Weight:          pulumi.Float64(100),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Netbox = Pulumi.Netbox;
    
    return await Deployment.RunAsync(() => 
    {
        var test = new Netbox.CustomField("test", new()
        {
            ContentTypes = new[]
            {
                "virtualization.vminterface",
            },
            Type = "text",
            ValidationRegex = "^.*$",
            Weight = 100,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.netbox.CustomField;
    import com.pulumi.netbox.CustomFieldArgs;
    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) {
            var test = new CustomField("test", CustomFieldArgs.builder()
                .contentTypes("virtualization.vminterface")
                .type("text")
                .validationRegex("^.*$")
                .weight(100)
                .build());
    
        }
    }
    
    resources:
      test:
        type: netbox:CustomField
        properties:
          contentTypes:
            - virtualization.vminterface
          type: text
          validationRegex: ^.*$
          weight: 100
    

    Create CustomField Resource

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

    Constructor syntax

    new CustomField(name: string, args: CustomFieldArgs, opts?: CustomResourceOptions);
    @overload
    def CustomField(resource_name: str,
                    args: CustomFieldArgs,
                    opts: Optional[ResourceOptions] = None)
    
    @overload
    def CustomField(resource_name: str,
                    opts: Optional[ResourceOptions] = None,
                    type: Optional[str] = None,
                    content_types: Optional[Sequence[str]] = None,
                    default: Optional[str] = None,
                    choice_set_id: Optional[float] = None,
                    description: Optional[str] = None,
                    group_name: Optional[str] = None,
                    label: Optional[str] = None,
                    name: Optional[str] = None,
                    required: Optional[bool] = None,
                    custom_field_id: Optional[str] = None,
                    validation_maximum: Optional[float] = None,
                    validation_minimum: Optional[float] = None,
                    validation_regex: Optional[str] = None,
                    weight: Optional[float] = None)
    func NewCustomField(ctx *Context, name string, args CustomFieldArgs, opts ...ResourceOption) (*CustomField, error)
    public CustomField(string name, CustomFieldArgs args, CustomResourceOptions? opts = null)
    public CustomField(String name, CustomFieldArgs args)
    public CustomField(String name, CustomFieldArgs args, CustomResourceOptions options)
    
    type: netbox:CustomField
    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 CustomFieldArgs
    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 CustomFieldArgs
    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 CustomFieldArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args CustomFieldArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args CustomFieldArgs
    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 customFieldResource = new Netbox.CustomField("customFieldResource", new()
    {
        Type = "string",
        ContentTypes = new[]
        {
            "string",
        },
        Default = "string",
        ChoiceSetId = 0,
        Description = "string",
        GroupName = "string",
        Label = "string",
        Name = "string",
        Required = false,
        CustomFieldId = "string",
        ValidationMaximum = 0,
        ValidationMinimum = 0,
        ValidationRegex = "string",
        Weight = 0,
    });
    
    example, err := netbox.NewCustomField(ctx, "customFieldResource", &netbox.CustomFieldArgs{
    	Type: pulumi.String("string"),
    	ContentTypes: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	Default:           pulumi.String("string"),
    	ChoiceSetId:       pulumi.Float64(0),
    	Description:       pulumi.String("string"),
    	GroupName:         pulumi.String("string"),
    	Label:             pulumi.String("string"),
    	Name:              pulumi.String("string"),
    	Required:          pulumi.Bool(false),
    	CustomFieldId:     pulumi.String("string"),
    	ValidationMaximum: pulumi.Float64(0),
    	ValidationMinimum: pulumi.Float64(0),
    	ValidationRegex:   pulumi.String("string"),
    	Weight:            pulumi.Float64(0),
    })
    
    var customFieldResource = new CustomField("customFieldResource", CustomFieldArgs.builder()
        .type("string")
        .contentTypes("string")
        .default_("string")
        .choiceSetId(0)
        .description("string")
        .groupName("string")
        .label("string")
        .name("string")
        .required(false)
        .customFieldId("string")
        .validationMaximum(0)
        .validationMinimum(0)
        .validationRegex("string")
        .weight(0)
        .build());
    
    custom_field_resource = netbox.CustomField("customFieldResource",
        type="string",
        content_types=["string"],
        default="string",
        choice_set_id=0,
        description="string",
        group_name="string",
        label="string",
        name="string",
        required=False,
        custom_field_id="string",
        validation_maximum=0,
        validation_minimum=0,
        validation_regex="string",
        weight=0)
    
    const customFieldResource = new netbox.CustomField("customFieldResource", {
        type: "string",
        contentTypes: ["string"],
        "default": "string",
        choiceSetId: 0,
        description: "string",
        groupName: "string",
        label: "string",
        name: "string",
        required: false,
        customFieldId: "string",
        validationMaximum: 0,
        validationMinimum: 0,
        validationRegex: "string",
        weight: 0,
    });
    
    type: netbox:CustomField
    properties:
        choiceSetId: 0
        contentTypes:
            - string
        customFieldId: string
        default: string
        description: string
        groupName: string
        label: string
        name: string
        required: false
        type: string
        validationMaximum: 0
        validationMinimum: 0
        validationRegex: string
        weight: 0
    

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

    ContentTypes List<string>
    Type string
    ChoiceSetId double
    CustomFieldId string
    The ID of this resource.
    Default string
    Description string
    GroupName string
    Label string
    Name string
    Required bool
    ValidationMaximum double
    ValidationMinimum double
    ValidationRegex string
    Weight double
    ContentTypes []string
    Type string
    ChoiceSetId float64
    CustomFieldId string
    The ID of this resource.
    Default string
    Description string
    GroupName string
    Label string
    Name string
    Required bool
    ValidationMaximum float64
    ValidationMinimum float64
    ValidationRegex string
    Weight float64
    contentTypes List<String>
    type String
    choiceSetId Double
    customFieldId String
    The ID of this resource.
    default_ String
    description String
    groupName String
    label String
    name String
    required Boolean
    validationMaximum Double
    validationMinimum Double
    validationRegex String
    weight Double
    contentTypes string[]
    type string
    choiceSetId number
    customFieldId string
    The ID of this resource.
    default string
    description string
    groupName string
    label string
    name string
    required boolean
    validationMaximum number
    validationMinimum number
    validationRegex string
    weight number
    content_types Sequence[str]
    type str
    choice_set_id float
    custom_field_id str
    The ID of this resource.
    default str
    description str
    group_name str
    label str
    name str
    required bool
    validation_maximum float
    validation_minimum float
    validation_regex str
    weight float
    contentTypes List<String>
    type String
    choiceSetId Number
    customFieldId String
    The ID of this resource.
    default String
    description String
    groupName String
    label String
    name String
    required Boolean
    validationMaximum Number
    validationMinimum Number
    validationRegex String
    weight Number

    Outputs

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

    Get an existing CustomField 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?: CustomFieldState, opts?: CustomResourceOptions): CustomField
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            choice_set_id: Optional[float] = None,
            content_types: Optional[Sequence[str]] = None,
            custom_field_id: Optional[str] = None,
            default: Optional[str] = None,
            description: Optional[str] = None,
            group_name: Optional[str] = None,
            label: Optional[str] = None,
            name: Optional[str] = None,
            required: Optional[bool] = None,
            type: Optional[str] = None,
            validation_maximum: Optional[float] = None,
            validation_minimum: Optional[float] = None,
            validation_regex: Optional[str] = None,
            weight: Optional[float] = None) -> CustomField
    func GetCustomField(ctx *Context, name string, id IDInput, state *CustomFieldState, opts ...ResourceOption) (*CustomField, error)
    public static CustomField Get(string name, Input<string> id, CustomFieldState? state, CustomResourceOptions? opts = null)
    public static CustomField get(String name, Output<String> id, CustomFieldState state, CustomResourceOptions options)
    resources:  _:    type: netbox:CustomField    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:
    ChoiceSetId double
    ContentTypes List<string>
    CustomFieldId string
    The ID of this resource.
    Default string
    Description string
    GroupName string
    Label string
    Name string
    Required bool
    Type string
    ValidationMaximum double
    ValidationMinimum double
    ValidationRegex string
    Weight double
    ChoiceSetId float64
    ContentTypes []string
    CustomFieldId string
    The ID of this resource.
    Default string
    Description string
    GroupName string
    Label string
    Name string
    Required bool
    Type string
    ValidationMaximum float64
    ValidationMinimum float64
    ValidationRegex string
    Weight float64
    choiceSetId Double
    contentTypes List<String>
    customFieldId String
    The ID of this resource.
    default_ String
    description String
    groupName String
    label String
    name String
    required Boolean
    type String
    validationMaximum Double
    validationMinimum Double
    validationRegex String
    weight Double
    choiceSetId number
    contentTypes string[]
    customFieldId string
    The ID of this resource.
    default string
    description string
    groupName string
    label string
    name string
    required boolean
    type string
    validationMaximum number
    validationMinimum number
    validationRegex string
    weight number
    choice_set_id float
    content_types Sequence[str]
    custom_field_id str
    The ID of this resource.
    default str
    description str
    group_name str
    label str
    name str
    required bool
    type str
    validation_maximum float
    validation_minimum float
    validation_regex str
    weight float
    choiceSetId Number
    contentTypes List<String>
    customFieldId String
    The ID of this resource.
    default String
    description String
    groupName String
    label String
    name String
    required Boolean
    type String
    validationMaximum Number
    validationMinimum Number
    validationRegex String
    weight Number

    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