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

netbox.Permission

Explore with Pulumi AI

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

    This resource manages the object-based permissions for Netbox users, built into the application.

    Object-based permissions enable an administrator to grant users or groups the ability to perform an action on arbitrary subsets of objects in NetBox, rather than all objects of a certain type. For more information, see the Netbox Object-Based Permissions Docs.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as netbox from "@pulumi/netbox";
    
    const testUser = new netbox.User("testUser", {
        username: "johndoe",
        password: "Abcdefghijkl1",
        active: true,
        staff: true,
    });
    const testPermission = new netbox.Permission("testPermission", {
        description: "my description",
        enabled: true,
        objectTypes: ["ipam.prefix"],
        actions: [
            "add",
            "change",
        ],
        users: [testUser.userId],
        constraints: JSON.stringify([{
            status: "active",
        }]),
    });
    
    import pulumi
    import json
    import pulumi_netbox as netbox
    
    test_user = netbox.User("testUser",
        username="johndoe",
        password="Abcdefghijkl1",
        active=True,
        staff=True)
    test_permission = netbox.Permission("testPermission",
        description="my description",
        enabled=True,
        object_types=["ipam.prefix"],
        actions=[
            "add",
            "change",
        ],
        users=[test_user.user_id],
        constraints=json.dumps([{
            "status": "active",
        }]))
    
    package main
    
    import (
    	"encoding/json"
    
    	"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 {
    		testUser, err := netbox.NewUser(ctx, "testUser", &netbox.UserArgs{
    			Username: pulumi.String("johndoe"),
    			Password: pulumi.String("Abcdefghijkl1"),
    			Active:   pulumi.Bool(true),
    			Staff:    pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		tmpJSON0, err := json.Marshal([]map[string]interface{}{
    			map[string]interface{}{
    				"status": "active",
    			},
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		_, err = netbox.NewPermission(ctx, "testPermission", &netbox.PermissionArgs{
    			Description: pulumi.String("my description"),
    			Enabled:     pulumi.Bool(true),
    			ObjectTypes: pulumi.StringArray{
    				pulumi.String("ipam.prefix"),
    			},
    			Actions: pulumi.StringArray{
    				pulumi.String("add"),
    				pulumi.String("change"),
    			},
    			Users: pulumi.Float64Array{
    				testUser.UserId,
    			},
    			Constraints: pulumi.String(json0),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using Netbox = Pulumi.Netbox;
    
    return await Deployment.RunAsync(() => 
    {
        var testUser = new Netbox.User("testUser", new()
        {
            Username = "johndoe",
            Password = "Abcdefghijkl1",
            Active = true,
            Staff = true,
        });
    
        var testPermission = new Netbox.Permission("testPermission", new()
        {
            Description = "my description",
            Enabled = true,
            ObjectTypes = new[]
            {
                "ipam.prefix",
            },
            Actions = new[]
            {
                "add",
                "change",
            },
            Users = new[]
            {
                testUser.UserId,
            },
            Constraints = JsonSerializer.Serialize(new[]
            {
                new Dictionary<string, object?>
                {
                    ["status"] = "active",
                },
            }),
        });
    
    });
    
    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.Permission;
    import com.pulumi.netbox.PermissionArgs;
    import static com.pulumi.codegen.internal.Serialization.*;
    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 testUser = new User("testUser", UserArgs.builder()
                .username("johndoe")
                .password("Abcdefghijkl1")
                .active(true)
                .staff(true)
                .build());
    
            var testPermission = new Permission("testPermission", PermissionArgs.builder()
                .description("my description")
                .enabled(true)
                .objectTypes("ipam.prefix")
                .actions(            
                    "add",
                    "change")
                .users(testUser.userId())
                .constraints(serializeJson(
                    jsonArray(jsonObject(
                        jsonProperty("status", "active")
                    ))))
                .build());
    
        }
    }
    
    resources:
      testUser:
        type: netbox:User
        properties:
          username: johndoe
          password: Abcdefghijkl1
          active: true
          staff: true
      testPermission:
        type: netbox:Permission
        properties:
          description: my description
          enabled: true
          objectTypes:
            - ipam.prefix
          actions:
            - add
            - change
          users:
            - ${testUser.userId}
          constraints:
            fn::toJSON:
              - status: active
    

    Create Permission Resource

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

    Constructor syntax

    new Permission(name: string, args: PermissionArgs, opts?: CustomResourceOptions);
    @overload
    def Permission(resource_name: str,
                   args: PermissionArgs,
                   opts: Optional[ResourceOptions] = None)
    
    @overload
    def Permission(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   actions: Optional[Sequence[str]] = None,
                   object_types: Optional[Sequence[str]] = None,
                   constraints: Optional[str] = None,
                   description: Optional[str] = None,
                   enabled: Optional[bool] = None,
                   groups: Optional[Sequence[float]] = None,
                   name: Optional[str] = None,
                   permission_id: Optional[str] = None,
                   users: Optional[Sequence[float]] = None)
    func NewPermission(ctx *Context, name string, args PermissionArgs, opts ...ResourceOption) (*Permission, error)
    public Permission(string name, PermissionArgs args, CustomResourceOptions? opts = null)
    public Permission(String name, PermissionArgs args)
    public Permission(String name, PermissionArgs args, CustomResourceOptions options)
    
    type: netbox:Permission
    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 PermissionArgs
    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 PermissionArgs
    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 PermissionArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args PermissionArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args PermissionArgs
    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 permissionResource = new Netbox.Permission("permissionResource", new()
    {
        Actions = new[]
        {
            "string",
        },
        ObjectTypes = new[]
        {
            "string",
        },
        Constraints = "string",
        Description = "string",
        Enabled = false,
        Groups = new[]
        {
            0,
        },
        Name = "string",
        PermissionId = "string",
        Users = new[]
        {
            0,
        },
    });
    
    example, err := netbox.NewPermission(ctx, "permissionResource", &netbox.PermissionArgs{
    	Actions: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	ObjectTypes: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	Constraints: pulumi.String("string"),
    	Description: pulumi.String("string"),
    	Enabled:     pulumi.Bool(false),
    	Groups: pulumi.Float64Array{
    		pulumi.Float64(0),
    	},
    	Name:         pulumi.String("string"),
    	PermissionId: pulumi.String("string"),
    	Users: pulumi.Float64Array{
    		pulumi.Float64(0),
    	},
    })
    
    var permissionResource = new Permission("permissionResource", PermissionArgs.builder()
        .actions("string")
        .objectTypes("string")
        .constraints("string")
        .description("string")
        .enabled(false)
        .groups(0)
        .name("string")
        .permissionId("string")
        .users(0)
        .build());
    
    permission_resource = netbox.Permission("permissionResource",
        actions=["string"],
        object_types=["string"],
        constraints="string",
        description="string",
        enabled=False,
        groups=[0],
        name="string",
        permission_id="string",
        users=[0])
    
    const permissionResource = new netbox.Permission("permissionResource", {
        actions: ["string"],
        objectTypes: ["string"],
        constraints: "string",
        description: "string",
        enabled: false,
        groups: [0],
        name: "string",
        permissionId: "string",
        users: [0],
    });
    
    type: netbox:Permission
    properties:
        actions:
            - string
        constraints: string
        description: string
        enabled: false
        groups:
            - 0
        name: string
        objectTypes:
            - string
        permissionId: string
        users:
            - 0
    

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

    Actions List<string>
    A list actions that are allowed on the object types. Acceptable values are view, add, change, or delete.
    ObjectTypes List<string>
    A list of object types that the permission object allows access to. Should be in a form the API can accept. For example: circuits.provider, dcim.inventoryitem, etc.
    Constraints string
    A JSON string of an arbitrary filter used to limit the granted action(s) to a specific subset of objects. For more information on correct syntax, see https://docs.netbox.dev/en/stable/administration/permissions/#constraints.
    Description string
    The description of the permission object.
    Enabled bool
    Whether the permission object is enabled or not. Defaults to true.
    Groups List<double>
    A list of group IDs that have been assigned to this permission object.
    Name string
    The name of the permission object.
    PermissionId string
    The ID of this resource.
    Users List<double>
    A list of user IDs that have been assigned to this permission object.
    Actions []string
    A list actions that are allowed on the object types. Acceptable values are view, add, change, or delete.
    ObjectTypes []string
    A list of object types that the permission object allows access to. Should be in a form the API can accept. For example: circuits.provider, dcim.inventoryitem, etc.
    Constraints string
    A JSON string of an arbitrary filter used to limit the granted action(s) to a specific subset of objects. For more information on correct syntax, see https://docs.netbox.dev/en/stable/administration/permissions/#constraints.
    Description string
    The description of the permission object.
    Enabled bool
    Whether the permission object is enabled or not. Defaults to true.
    Groups []float64
    A list of group IDs that have been assigned to this permission object.
    Name string
    The name of the permission object.
    PermissionId string
    The ID of this resource.
    Users []float64
    A list of user IDs that have been assigned to this permission object.
    actions List<String>
    A list actions that are allowed on the object types. Acceptable values are view, add, change, or delete.
    objectTypes List<String>
    A list of object types that the permission object allows access to. Should be in a form the API can accept. For example: circuits.provider, dcim.inventoryitem, etc.
    constraints String
    A JSON string of an arbitrary filter used to limit the granted action(s) to a specific subset of objects. For more information on correct syntax, see https://docs.netbox.dev/en/stable/administration/permissions/#constraints.
    description String
    The description of the permission object.
    enabled Boolean
    Whether the permission object is enabled or not. Defaults to true.
    groups List<Double>
    A list of group IDs that have been assigned to this permission object.
    name String
    The name of the permission object.
    permissionId String
    The ID of this resource.
    users List<Double>
    A list of user IDs that have been assigned to this permission object.
    actions string[]
    A list actions that are allowed on the object types. Acceptable values are view, add, change, or delete.
    objectTypes string[]
    A list of object types that the permission object allows access to. Should be in a form the API can accept. For example: circuits.provider, dcim.inventoryitem, etc.
    constraints string
    A JSON string of an arbitrary filter used to limit the granted action(s) to a specific subset of objects. For more information on correct syntax, see https://docs.netbox.dev/en/stable/administration/permissions/#constraints.
    description string
    The description of the permission object.
    enabled boolean
    Whether the permission object is enabled or not. Defaults to true.
    groups number[]
    A list of group IDs that have been assigned to this permission object.
    name string
    The name of the permission object.
    permissionId string
    The ID of this resource.
    users number[]
    A list of user IDs that have been assigned to this permission object.
    actions Sequence[str]
    A list actions that are allowed on the object types. Acceptable values are view, add, change, or delete.
    object_types Sequence[str]
    A list of object types that the permission object allows access to. Should be in a form the API can accept. For example: circuits.provider, dcim.inventoryitem, etc.
    constraints str
    A JSON string of an arbitrary filter used to limit the granted action(s) to a specific subset of objects. For more information on correct syntax, see https://docs.netbox.dev/en/stable/administration/permissions/#constraints.
    description str
    The description of the permission object.
    enabled bool
    Whether the permission object is enabled or not. Defaults to true.
    groups Sequence[float]
    A list of group IDs that have been assigned to this permission object.
    name str
    The name of the permission object.
    permission_id str
    The ID of this resource.
    users Sequence[float]
    A list of user IDs that have been assigned to this permission object.
    actions List<String>
    A list actions that are allowed on the object types. Acceptable values are view, add, change, or delete.
    objectTypes List<String>
    A list of object types that the permission object allows access to. Should be in a form the API can accept. For example: circuits.provider, dcim.inventoryitem, etc.
    constraints String
    A JSON string of an arbitrary filter used to limit the granted action(s) to a specific subset of objects. For more information on correct syntax, see https://docs.netbox.dev/en/stable/administration/permissions/#constraints.
    description String
    The description of the permission object.
    enabled Boolean
    Whether the permission object is enabled or not. Defaults to true.
    groups List<Number>
    A list of group IDs that have been assigned to this permission object.
    name String
    The name of the permission object.
    permissionId String
    The ID of this resource.
    users List<Number>
    A list of user IDs that have been assigned to this permission object.

    Outputs

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

    Get an existing Permission 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?: PermissionState, opts?: CustomResourceOptions): Permission
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            actions: Optional[Sequence[str]] = None,
            constraints: Optional[str] = None,
            description: Optional[str] = None,
            enabled: Optional[bool] = None,
            groups: Optional[Sequence[float]] = None,
            name: Optional[str] = None,
            object_types: Optional[Sequence[str]] = None,
            permission_id: Optional[str] = None,
            users: Optional[Sequence[float]] = None) -> Permission
    func GetPermission(ctx *Context, name string, id IDInput, state *PermissionState, opts ...ResourceOption) (*Permission, error)
    public static Permission Get(string name, Input<string> id, PermissionState? state, CustomResourceOptions? opts = null)
    public static Permission get(String name, Output<String> id, PermissionState state, CustomResourceOptions options)
    resources:  _:    type: netbox:Permission    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:
    Actions List<string>
    A list actions that are allowed on the object types. Acceptable values are view, add, change, or delete.
    Constraints string
    A JSON string of an arbitrary filter used to limit the granted action(s) to a specific subset of objects. For more information on correct syntax, see https://docs.netbox.dev/en/stable/administration/permissions/#constraints.
    Description string
    The description of the permission object.
    Enabled bool
    Whether the permission object is enabled or not. Defaults to true.
    Groups List<double>
    A list of group IDs that have been assigned to this permission object.
    Name string
    The name of the permission object.
    ObjectTypes List<string>
    A list of object types that the permission object allows access to. Should be in a form the API can accept. For example: circuits.provider, dcim.inventoryitem, etc.
    PermissionId string
    The ID of this resource.
    Users List<double>
    A list of user IDs that have been assigned to this permission object.
    Actions []string
    A list actions that are allowed on the object types. Acceptable values are view, add, change, or delete.
    Constraints string
    A JSON string of an arbitrary filter used to limit the granted action(s) to a specific subset of objects. For more information on correct syntax, see https://docs.netbox.dev/en/stable/administration/permissions/#constraints.
    Description string
    The description of the permission object.
    Enabled bool
    Whether the permission object is enabled or not. Defaults to true.
    Groups []float64
    A list of group IDs that have been assigned to this permission object.
    Name string
    The name of the permission object.
    ObjectTypes []string
    A list of object types that the permission object allows access to. Should be in a form the API can accept. For example: circuits.provider, dcim.inventoryitem, etc.
    PermissionId string
    The ID of this resource.
    Users []float64
    A list of user IDs that have been assigned to this permission object.
    actions List<String>
    A list actions that are allowed on the object types. Acceptable values are view, add, change, or delete.
    constraints String
    A JSON string of an arbitrary filter used to limit the granted action(s) to a specific subset of objects. For more information on correct syntax, see https://docs.netbox.dev/en/stable/administration/permissions/#constraints.
    description String
    The description of the permission object.
    enabled Boolean
    Whether the permission object is enabled or not. Defaults to true.
    groups List<Double>
    A list of group IDs that have been assigned to this permission object.
    name String
    The name of the permission object.
    objectTypes List<String>
    A list of object types that the permission object allows access to. Should be in a form the API can accept. For example: circuits.provider, dcim.inventoryitem, etc.
    permissionId String
    The ID of this resource.
    users List<Double>
    A list of user IDs that have been assigned to this permission object.
    actions string[]
    A list actions that are allowed on the object types. Acceptable values are view, add, change, or delete.
    constraints string
    A JSON string of an arbitrary filter used to limit the granted action(s) to a specific subset of objects. For more information on correct syntax, see https://docs.netbox.dev/en/stable/administration/permissions/#constraints.
    description string
    The description of the permission object.
    enabled boolean
    Whether the permission object is enabled or not. Defaults to true.
    groups number[]
    A list of group IDs that have been assigned to this permission object.
    name string
    The name of the permission object.
    objectTypes string[]
    A list of object types that the permission object allows access to. Should be in a form the API can accept. For example: circuits.provider, dcim.inventoryitem, etc.
    permissionId string
    The ID of this resource.
    users number[]
    A list of user IDs that have been assigned to this permission object.
    actions Sequence[str]
    A list actions that are allowed on the object types. Acceptable values are view, add, change, or delete.
    constraints str
    A JSON string of an arbitrary filter used to limit the granted action(s) to a specific subset of objects. For more information on correct syntax, see https://docs.netbox.dev/en/stable/administration/permissions/#constraints.
    description str
    The description of the permission object.
    enabled bool
    Whether the permission object is enabled or not. Defaults to true.
    groups Sequence[float]
    A list of group IDs that have been assigned to this permission object.
    name str
    The name of the permission object.
    object_types Sequence[str]
    A list of object types that the permission object allows access to. Should be in a form the API can accept. For example: circuits.provider, dcim.inventoryitem, etc.
    permission_id str
    The ID of this resource.
    users Sequence[float]
    A list of user IDs that have been assigned to this permission object.
    actions List<String>
    A list actions that are allowed on the object types. Acceptable values are view, add, change, or delete.
    constraints String
    A JSON string of an arbitrary filter used to limit the granted action(s) to a specific subset of objects. For more information on correct syntax, see https://docs.netbox.dev/en/stable/administration/permissions/#constraints.
    description String
    The description of the permission object.
    enabled Boolean
    Whether the permission object is enabled or not. Defaults to true.
    groups List<Number>
    A list of group IDs that have been assigned to this permission object.
    name String
    The name of the permission object.
    objectTypes List<String>
    A list of object types that the permission object allows access to. Should be in a form the API can accept. For example: circuits.provider, dcim.inventoryitem, etc.
    permissionId String
    The ID of this resource.
    users List<Number>
    A list of user IDs that have been assigned to this permission object.

    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