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

netbox.Token

Explore with Pulumi AI

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

    From the official documentation:

    A token is a unique identifier mapped to a NetBox user account. Each user may have one or more tokens which he or she can use for authentication when making REST API requests. To create a token, navigate to the API tokens page under your user profile.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as netbox from "@pulumi/netbox";
    
    const test = new netbox.User("test", {
        username: "johndoe",
        password: "Abcdefghijkl1",
    });
    const testBasic = new netbox.Token("testBasic", {
        userId: test.userId,
        key: "0123456789012345678901234567890123456789",
        allowedIps: ["2.4.8.16/32"],
        writeEnabled: false,
    });
    
    import pulumi
    import pulumi_netbox as netbox
    
    test = netbox.User("test",
        username="johndoe",
        password="Abcdefghijkl1")
    test_basic = netbox.Token("testBasic",
        user_id=test.user_id,
        key="0123456789012345678901234567890123456789",
        allowed_ips=["2.4.8.16/32"],
        write_enabled=False)
    
    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 {
    		test, err := netbox.NewUser(ctx, "test", &netbox.UserArgs{
    			Username: pulumi.String("johndoe"),
    			Password: pulumi.String("Abcdefghijkl1"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = netbox.NewToken(ctx, "testBasic", &netbox.TokenArgs{
    			UserId: test.UserId,
    			Key:    pulumi.String("0123456789012345678901234567890123456789"),
    			AllowedIps: pulumi.StringArray{
    				pulumi.String("2.4.8.16/32"),
    			},
    			WriteEnabled: pulumi.Bool(false),
    		})
    		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.User("test", new()
        {
            Username = "johndoe",
            Password = "Abcdefghijkl1",
        });
    
        var testBasic = new Netbox.Token("testBasic", new()
        {
            UserId = test.UserId,
            Key = "0123456789012345678901234567890123456789",
            AllowedIps = new[]
            {
                "2.4.8.16/32",
            },
            WriteEnabled = false,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.netbox.User;
    import com.pulumi.netbox.UserArgs;
    import com.pulumi.netbox.Token;
    import com.pulumi.netbox.TokenArgs;
    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 User("test", UserArgs.builder()
                .username("johndoe")
                .password("Abcdefghijkl1")
                .build());
    
            var testBasic = new Token("testBasic", TokenArgs.builder()
                .userId(test.userId())
                .key("0123456789012345678901234567890123456789")
                .allowedIps("2.4.8.16/32")
                .writeEnabled(false)
                .build());
    
        }
    }
    
    resources:
      test:
        type: netbox:User
        properties:
          username: johndoe
          password: Abcdefghijkl1
      testBasic:
        type: netbox:Token
        properties:
          userId: ${test.userId}
          key: '0123456789012345678901234567890123456789'
          allowedIps:
            - 2.4.8.16/32
          writeEnabled: false
    

    Create Token Resource

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

    Constructor syntax

    new Token(name: string, args: TokenArgs, opts?: CustomResourceOptions);
    @overload
    def Token(resource_name: str,
              args: TokenArgs,
              opts: Optional[ResourceOptions] = None)
    
    @overload
    def Token(resource_name: str,
              opts: Optional[ResourceOptions] = None,
              user_id: Optional[float] = None,
              allowed_ips: Optional[Sequence[str]] = None,
              description: Optional[str] = None,
              key: Optional[str] = None,
              token_id: Optional[str] = None,
              write_enabled: Optional[bool] = None)
    func NewToken(ctx *Context, name string, args TokenArgs, opts ...ResourceOption) (*Token, error)
    public Token(string name, TokenArgs args, CustomResourceOptions? opts = null)
    public Token(String name, TokenArgs args)
    public Token(String name, TokenArgs args, CustomResourceOptions options)
    
    type: netbox:Token
    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 TokenArgs
    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 TokenArgs
    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 TokenArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args TokenArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args TokenArgs
    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 tokenResource = new Netbox.Token("tokenResource", new()
    {
        UserId = 0,
        AllowedIps = new[]
        {
            "string",
        },
        Description = "string",
        Key = "string",
        TokenId = "string",
        WriteEnabled = false,
    });
    
    example, err := netbox.NewToken(ctx, "tokenResource", &netbox.TokenArgs{
    	UserId: pulumi.Float64(0),
    	AllowedIps: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	Description:  pulumi.String("string"),
    	Key:          pulumi.String("string"),
    	TokenId:      pulumi.String("string"),
    	WriteEnabled: pulumi.Bool(false),
    })
    
    var tokenResource = new Token("tokenResource", TokenArgs.builder()
        .userId(0)
        .allowedIps("string")
        .description("string")
        .key("string")
        .tokenId("string")
        .writeEnabled(false)
        .build());
    
    token_resource = netbox.Token("tokenResource",
        user_id=0,
        allowed_ips=["string"],
        description="string",
        key="string",
        token_id="string",
        write_enabled=False)
    
    const tokenResource = new netbox.Token("tokenResource", {
        userId: 0,
        allowedIps: ["string"],
        description: "string",
        key: "string",
        tokenId: "string",
        writeEnabled: false,
    });
    
    type: netbox:Token
    properties:
        allowedIps:
            - string
        description: string
        key: string
        tokenId: string
        userId: 0
        writeEnabled: false
    

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

    UserId double
    AllowedIps List<string>
    Description string
    Key string
    TokenId string
    The ID of this resource.
    WriteEnabled bool
    UserId float64
    AllowedIps []string
    Description string
    Key string
    TokenId string
    The ID of this resource.
    WriteEnabled bool
    userId Double
    allowedIps List<String>
    description String
    key String
    tokenId String
    The ID of this resource.
    writeEnabled Boolean
    userId number
    allowedIps string[]
    description string
    key string
    tokenId string
    The ID of this resource.
    writeEnabled boolean
    user_id float
    allowed_ips Sequence[str]
    description str
    key str
    token_id str
    The ID of this resource.
    write_enabled bool
    userId Number
    allowedIps List<String>
    description String
    key String
    tokenId String
    The ID of this resource.
    writeEnabled Boolean

    Outputs

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

    Expires string
    Id string
    The provider-assigned unique ID for this managed resource.
    LastUsed string
    Expires string
    Id string
    The provider-assigned unique ID for this managed resource.
    LastUsed string
    expires String
    id String
    The provider-assigned unique ID for this managed resource.
    lastUsed String
    expires string
    id string
    The provider-assigned unique ID for this managed resource.
    lastUsed string
    expires str
    id str
    The provider-assigned unique ID for this managed resource.
    last_used str
    expires String
    id String
    The provider-assigned unique ID for this managed resource.
    lastUsed String

    Look up Existing Token Resource

    Get an existing Token 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?: TokenState, opts?: CustomResourceOptions): Token
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            allowed_ips: Optional[Sequence[str]] = None,
            description: Optional[str] = None,
            expires: Optional[str] = None,
            key: Optional[str] = None,
            last_used: Optional[str] = None,
            token_id: Optional[str] = None,
            user_id: Optional[float] = None,
            write_enabled: Optional[bool] = None) -> Token
    func GetToken(ctx *Context, name string, id IDInput, state *TokenState, opts ...ResourceOption) (*Token, error)
    public static Token Get(string name, Input<string> id, TokenState? state, CustomResourceOptions? opts = null)
    public static Token get(String name, Output<String> id, TokenState state, CustomResourceOptions options)
    resources:  _:    type: netbox:Token    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:
    AllowedIps List<string>
    Description string
    Expires string
    Key string
    LastUsed string
    TokenId string
    The ID of this resource.
    UserId double
    WriteEnabled bool
    AllowedIps []string
    Description string
    Expires string
    Key string
    LastUsed string
    TokenId string
    The ID of this resource.
    UserId float64
    WriteEnabled bool
    allowedIps List<String>
    description String
    expires String
    key String
    lastUsed String
    tokenId String
    The ID of this resource.
    userId Double
    writeEnabled Boolean
    allowedIps string[]
    description string
    expires string
    key string
    lastUsed string
    tokenId string
    The ID of this resource.
    userId number
    writeEnabled boolean
    allowed_ips Sequence[str]
    description str
    expires str
    key str
    last_used str
    token_id str
    The ID of this resource.
    user_id float
    write_enabled bool
    allowedIps List<String>
    description String
    expires String
    key String
    lastUsed String
    tokenId String
    The ID of this resource.
    userId Number
    writeEnabled Boolean

    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