1. Packages
  2. Azure DevOps Provider
  3. API Docs
  4. LibraryPermissions
Azure DevOps v3.8.0 published on Monday, Mar 17, 2025 by Pulumi

azuredevops.LibraryPermissions

Explore with Pulumi AI

Manages permissions for a Library

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as azuredevops from "@pulumi/azuredevops";

const project = new azuredevops.Project("project", {
    name: "Testing",
    description: "Testing-description",
    visibility: "private",
    versionControl: "Git",
    workItemTemplate: "Agile",
});
const tf_project_readers = azuredevops.getGroupOutput({
    projectId: project.id,
    name: "Readers",
});
const permissions = new azuredevops.LibraryPermissions("permissions", {
    projectId: project.id,
    principal: tf_project_readers.apply(tf_project_readers => tf_project_readers.id),
    permissions: {
        View: "allow",
        Administer: "allow",
        Use: "allow",
    },
});
Copy
import pulumi
import pulumi_azuredevops as azuredevops

project = azuredevops.Project("project",
    name="Testing",
    description="Testing-description",
    visibility="private",
    version_control="Git",
    work_item_template="Agile")
tf_project_readers = azuredevops.get_group_output(project_id=project.id,
    name="Readers")
permissions = azuredevops.LibraryPermissions("permissions",
    project_id=project.id,
    principal=tf_project_readers.id,
    permissions={
        "View": "allow",
        "Administer": "allow",
        "Use": "allow",
    })
Copy
package main

import (
	"github.com/pulumi/pulumi-azuredevops/sdk/v3/go/azuredevops"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		project, err := azuredevops.NewProject(ctx, "project", &azuredevops.ProjectArgs{
			Name:             pulumi.String("Testing"),
			Description:      pulumi.String("Testing-description"),
			Visibility:       pulumi.String("private"),
			VersionControl:   pulumi.String("Git"),
			WorkItemTemplate: pulumi.String("Agile"),
		})
		if err != nil {
			return err
		}
		tf_project_readers := azuredevops.LookupGroupOutput(ctx, azuredevops.GetGroupOutputArgs{
			ProjectId: project.ID(),
			Name:      pulumi.String("Readers"),
		}, nil)
		_, err = azuredevops.NewLibraryPermissions(ctx, "permissions", &azuredevops.LibraryPermissionsArgs{
			ProjectId: project.ID(),
			Principal: pulumi.String(tf_project_readers.ApplyT(func(tf_project_readers azuredevops.GetGroupResult) (*string, error) {
				return &tf_project_readers.Id, nil
			}).(pulumi.StringPtrOutput)),
			Permissions: pulumi.StringMap{
				"View":       pulumi.String("allow"),
				"Administer": pulumi.String("allow"),
				"Use":        pulumi.String("allow"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureDevOps = Pulumi.AzureDevOps;

return await Deployment.RunAsync(() => 
{
    var project = new AzureDevOps.Project("project", new()
    {
        Name = "Testing",
        Description = "Testing-description",
        Visibility = "private",
        VersionControl = "Git",
        WorkItemTemplate = "Agile",
    });

    var tf_project_readers = AzureDevOps.GetGroup.Invoke(new()
    {
        ProjectId = project.Id,
        Name = "Readers",
    });

    var permissions = new AzureDevOps.LibraryPermissions("permissions", new()
    {
        ProjectId = project.Id,
        Principal = tf_project_readers.Apply(tf_project_readers => tf_project_readers.Apply(getGroupResult => getGroupResult.Id)),
        Permissions = 
        {
            { "View", "allow" },
            { "Administer", "allow" },
            { "Use", "allow" },
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azuredevops.Project;
import com.pulumi.azuredevops.ProjectArgs;
import com.pulumi.azuredevops.AzuredevopsFunctions;
import com.pulumi.azuredevops.inputs.GetGroupArgs;
import com.pulumi.azuredevops.LibraryPermissions;
import com.pulumi.azuredevops.LibraryPermissionsArgs;
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 project = new Project("project", ProjectArgs.builder()
            .name("Testing")
            .description("Testing-description")
            .visibility("private")
            .versionControl("Git")
            .workItemTemplate("Agile")
            .build());

        final var tf-project-readers = AzuredevopsFunctions.getGroup(GetGroupArgs.builder()
            .projectId(project.id())
            .name("Readers")
            .build());

        var permissions = new LibraryPermissions("permissions", LibraryPermissionsArgs.builder()
            .projectId(project.id())
            .principal(tf_project_readers.applyValue(tf_project_readers -> tf_project_readers.id()))
            .permissions(Map.ofEntries(
                Map.entry("View", "allow"),
                Map.entry("Administer", "allow"),
                Map.entry("Use", "allow")
            ))
            .build());

    }
}
Copy
resources:
  project:
    type: azuredevops:Project
    properties:
      name: Testing
      description: Testing-description
      visibility: private
      versionControl: Git
      workItemTemplate: Agile
  permissions:
    type: azuredevops:LibraryPermissions
    properties:
      projectId: ${project.id}
      principal: ${["tf-project-readers"].id}
      permissions:
        View: allow
        Administer: allow
        Use: allow
variables:
  tf-project-readers:
    fn::invoke:
      function: azuredevops:getGroup
      arguments:
        projectId: ${project.id}
        name: Readers
Copy

Roles

The Azure DevOps UI uses roles to assign permissions for the Library.

RoleAllowed Permissions
ReaderView
CreatorView, Create
UserView, Use
AdministratorView, Use, Administer

PAT Permissions Required

  • Project & Team: vso.security_manage - Grants the ability to read, write, and manage security permissions.

Create LibraryPermissions Resource

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

Constructor syntax

new LibraryPermissions(name: string, args: LibraryPermissionsArgs, opts?: CustomResourceOptions);
@overload
def LibraryPermissions(resource_name: str,
                       args: LibraryPermissionsArgs,
                       opts: Optional[ResourceOptions] = None)

@overload
def LibraryPermissions(resource_name: str,
                       opts: Optional[ResourceOptions] = None,
                       permissions: Optional[Mapping[str, str]] = None,
                       principal: Optional[str] = None,
                       project_id: Optional[str] = None,
                       replace: Optional[bool] = None)
func NewLibraryPermissions(ctx *Context, name string, args LibraryPermissionsArgs, opts ...ResourceOption) (*LibraryPermissions, error)
public LibraryPermissions(string name, LibraryPermissionsArgs args, CustomResourceOptions? opts = null)
public LibraryPermissions(String name, LibraryPermissionsArgs args)
public LibraryPermissions(String name, LibraryPermissionsArgs args, CustomResourceOptions options)
type: azuredevops:LibraryPermissions
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. LibraryPermissionsArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. LibraryPermissionsArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. LibraryPermissionsArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. LibraryPermissionsArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. LibraryPermissionsArgs
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 libraryPermissionsResource = new AzureDevOps.LibraryPermissions("libraryPermissionsResource", new()
{
    Permissions = 
    {
        { "string", "string" },
    },
    Principal = "string",
    ProjectId = "string",
    Replace = false,
});
Copy
example, err := azuredevops.NewLibraryPermissions(ctx, "libraryPermissionsResource", &azuredevops.LibraryPermissionsArgs{
	Permissions: pulumi.StringMap{
		"string": pulumi.String("string"),
	},
	Principal: pulumi.String("string"),
	ProjectId: pulumi.String("string"),
	Replace:   pulumi.Bool(false),
})
Copy
var libraryPermissionsResource = new LibraryPermissions("libraryPermissionsResource", LibraryPermissionsArgs.builder()
    .permissions(Map.of("string", "string"))
    .principal("string")
    .projectId("string")
    .replace(false)
    .build());
Copy
library_permissions_resource = azuredevops.LibraryPermissions("libraryPermissionsResource",
    permissions={
        "string": "string",
    },
    principal="string",
    project_id="string",
    replace=False)
Copy
const libraryPermissionsResource = new azuredevops.LibraryPermissions("libraryPermissionsResource", {
    permissions: {
        string: "string",
    },
    principal: "string",
    projectId: "string",
    replace: false,
});
Copy
type: azuredevops:LibraryPermissions
properties:
    permissions:
        string: string
    principal: string
    projectId: string
    replace: false
Copy

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

Permissions This property is required. Dictionary<string, string>

the permissions to assign. The following permissions are available.

| Permission | Description | |-------------|---------------------------| | View | View library item | | Administer | Administer library item | | Create | Create library item | | ViewSecrets | View library item secrets | | Use | Use library item | | Owner | Owner library item |

Principal
This property is required.
Changes to this property will trigger replacement.
string
The group principal to assign the permissions.
ProjectId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the project.
Replace bool
Replace (true) or merge (false) the permissions. Default: true
Permissions This property is required. map[string]string

the permissions to assign. The following permissions are available.

| Permission | Description | |-------------|---------------------------| | View | View library item | | Administer | Administer library item | | Create | Create library item | | ViewSecrets | View library item secrets | | Use | Use library item | | Owner | Owner library item |

Principal
This property is required.
Changes to this property will trigger replacement.
string
The group principal to assign the permissions.
ProjectId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the project.
Replace bool
Replace (true) or merge (false) the permissions. Default: true
permissions This property is required. Map<String,String>

the permissions to assign. The following permissions are available.

| Permission | Description | |-------------|---------------------------| | View | View library item | | Administer | Administer library item | | Create | Create library item | | ViewSecrets | View library item secrets | | Use | Use library item | | Owner | Owner library item |

principal
This property is required.
Changes to this property will trigger replacement.
String
The group principal to assign the permissions.
projectId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the project.
replace Boolean
Replace (true) or merge (false) the permissions. Default: true
permissions This property is required. {[key: string]: string}

the permissions to assign. The following permissions are available.

| Permission | Description | |-------------|---------------------------| | View | View library item | | Administer | Administer library item | | Create | Create library item | | ViewSecrets | View library item secrets | | Use | Use library item | | Owner | Owner library item |

principal
This property is required.
Changes to this property will trigger replacement.
string
The group principal to assign the permissions.
projectId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the project.
replace boolean
Replace (true) or merge (false) the permissions. Default: true
permissions This property is required. Mapping[str, str]

the permissions to assign. The following permissions are available.

| Permission | Description | |-------------|---------------------------| | View | View library item | | Administer | Administer library item | | Create | Create library item | | ViewSecrets | View library item secrets | | Use | Use library item | | Owner | Owner library item |

principal
This property is required.
Changes to this property will trigger replacement.
str
The group principal to assign the permissions.
project_id
This property is required.
Changes to this property will trigger replacement.
str
The ID of the project.
replace bool
Replace (true) or merge (false) the permissions. Default: true
permissions This property is required. Map<String>

the permissions to assign. The following permissions are available.

| Permission | Description | |-------------|---------------------------| | View | View library item | | Administer | Administer library item | | Create | Create library item | | ViewSecrets | View library item secrets | | Use | Use library item | | Owner | Owner library item |

principal
This property is required.
Changes to this property will trigger replacement.
String
The group principal to assign the permissions.
projectId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the project.
replace Boolean
Replace (true) or merge (false) the permissions. Default: true

Outputs

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

Get an existing LibraryPermissions 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?: LibraryPermissionsState, opts?: CustomResourceOptions): LibraryPermissions
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        permissions: Optional[Mapping[str, str]] = None,
        principal: Optional[str] = None,
        project_id: Optional[str] = None,
        replace: Optional[bool] = None) -> LibraryPermissions
func GetLibraryPermissions(ctx *Context, name string, id IDInput, state *LibraryPermissionsState, opts ...ResourceOption) (*LibraryPermissions, error)
public static LibraryPermissions Get(string name, Input<string> id, LibraryPermissionsState? state, CustomResourceOptions? opts = null)
public static LibraryPermissions get(String name, Output<String> id, LibraryPermissionsState state, CustomResourceOptions options)
resources:  _:    type: azuredevops:LibraryPermissions    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
Permissions Dictionary<string, string>

the permissions to assign. The following permissions are available.

| Permission | Description | |-------------|---------------------------| | View | View library item | | Administer | Administer library item | | Create | Create library item | | ViewSecrets | View library item secrets | | Use | Use library item | | Owner | Owner library item |

Principal Changes to this property will trigger replacement. string
The group principal to assign the permissions.
ProjectId Changes to this property will trigger replacement. string
The ID of the project.
Replace bool
Replace (true) or merge (false) the permissions. Default: true
Permissions map[string]string

the permissions to assign. The following permissions are available.

| Permission | Description | |-------------|---------------------------| | View | View library item | | Administer | Administer library item | | Create | Create library item | | ViewSecrets | View library item secrets | | Use | Use library item | | Owner | Owner library item |

Principal Changes to this property will trigger replacement. string
The group principal to assign the permissions.
ProjectId Changes to this property will trigger replacement. string
The ID of the project.
Replace bool
Replace (true) or merge (false) the permissions. Default: true
permissions Map<String,String>

the permissions to assign. The following permissions are available.

| Permission | Description | |-------------|---------------------------| | View | View library item | | Administer | Administer library item | | Create | Create library item | | ViewSecrets | View library item secrets | | Use | Use library item | | Owner | Owner library item |

principal Changes to this property will trigger replacement. String
The group principal to assign the permissions.
projectId Changes to this property will trigger replacement. String
The ID of the project.
replace Boolean
Replace (true) or merge (false) the permissions. Default: true
permissions {[key: string]: string}

the permissions to assign. The following permissions are available.

| Permission | Description | |-------------|---------------------------| | View | View library item | | Administer | Administer library item | | Create | Create library item | | ViewSecrets | View library item secrets | | Use | Use library item | | Owner | Owner library item |

principal Changes to this property will trigger replacement. string
The group principal to assign the permissions.
projectId Changes to this property will trigger replacement. string
The ID of the project.
replace boolean
Replace (true) or merge (false) the permissions. Default: true
permissions Mapping[str, str]

the permissions to assign. The following permissions are available.

| Permission | Description | |-------------|---------------------------| | View | View library item | | Administer | Administer library item | | Create | Create library item | | ViewSecrets | View library item secrets | | Use | Use library item | | Owner | Owner library item |

principal Changes to this property will trigger replacement. str
The group principal to assign the permissions.
project_id Changes to this property will trigger replacement. str
The ID of the project.
replace bool
Replace (true) or merge (false) the permissions. Default: true
permissions Map<String>

the permissions to assign. The following permissions are available.

| Permission | Description | |-------------|---------------------------| | View | View library item | | Administer | Administer library item | | Create | Create library item | | ViewSecrets | View library item secrets | | Use | Use library item | | Owner | Owner library item |

principal Changes to this property will trigger replacement. String
The group principal to assign the permissions.
projectId Changes to this property will trigger replacement. String
The ID of the project.
replace Boolean
Replace (true) or merge (false) the permissions. Default: true

Import

The resource does not support import.

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
Azure DevOps pulumi/pulumi-azuredevops
License
Apache-2.0
Notes
This Pulumi package is based on the azuredevops Terraform Provider.