UNPKG

@pulumi/azuredevops

Version:

A Pulumi package for creating and managing Azure DevOps.

266 lines 10.1 kB
"use strict"; // *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.GitPermissions = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * Manages permissions for Git repositories. * * > **Note** Permissions can be assigned to group principals and not to single user principals. * * ## Permission levels * * Permission for Git Repositories within Azure DevOps can be applied on three different levels. * Those levels are reflected by specifying (or omitting) values for the arguments `projectId`, `repositoryId` and `branchName`. * * ### Project level * * Permissions for all Git Repositories inside a project (existing or newly created ones) are specified, if only the argument `projectId` has a value. * * #### Example usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azuredevops from "@pulumi/azuredevops"; * * const example = new azuredevops.Project("example", { * name: "Example Project", * workItemTemplate: "Agile", * versionControl: "Git", * visibility: "private", * description: "Managed by Pulumi", * }); * const example_readers = azuredevops.getGroupOutput({ * projectId: example.id, * name: "Readers", * }); * const example_permissions = new azuredevops.GitPermissions("example-permissions", { * projectId: example.id, * principal: example_readers.apply(example_readers => example_readers.id), * permissions: { * CreateRepository: "Deny", * DeleteRepository: "Deny", * RenameRepository: "NotSet", * }, * }); * ``` * * ### Repository level * * Permissions for a specific Git Repository and all existing or newly created branches are specified if the arguments `projectId` and `repositoryId` are set. * * #### Example usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azuredevops from "@pulumi/azuredevops"; * * const example = new azuredevops.Project("example", { * name: "Example Project", * workItemTemplate: "Agile", * versionControl: "Git", * visibility: "private", * description: "Managed by Pulumi", * }); * const example_group = azuredevops.getGroup({ * name: "Project Collection Administrators", * }); * const exampleGit = new azuredevops.Git("example", { * projectId: example.id, * name: "Example Empty Git Repository", * initialization: { * initType: "Clean", * }, * }); * const example_permissions = new azuredevops.GitPermissions("example-permissions", { * projectId: exampleGit.projectId, * repositoryId: exampleGit.id, * principal: example_group.then(example_group => example_group.id), * permissions: { * RemoveOthersLocks: "Allow", * ManagePermissions: "Deny", * CreateTag: "Deny", * CreateBranch: "NotSet", * }, * }); * ``` * * ### Branch level * * Permissions for a specific branch inside a Git Repository are specified if all above mentioned the arguments are set. * * #### Example usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azuredevops from "@pulumi/azuredevops"; * * const example = new azuredevops.Project("example", { * name: "Example Project", * workItemTemplate: "Agile", * versionControl: "Git", * visibility: "private", * description: "Managed by Pulumi", * }); * const exampleGit = new azuredevops.Git("example", { * projectId: example.id, * name: "Example Empty Git Repository", * initialization: { * initType: "Clean", * }, * }); * const example_group = azuredevops.getGroup({ * name: "Project Collection Administrators", * }); * const example_permissions = new azuredevops.GitPermissions("example-permissions", { * projectId: exampleGit.projectId, * repositoryId: exampleGit.id, * branchName: "refs/heads/master", * principal: example_group.then(example_group => example_group.id), * permissions: { * RemoveOthersLocks: "Allow", * ForcePush: "Deny", * }, * }); * ``` * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azuredevops from "@pulumi/azuredevops"; * * const example = new azuredevops.Project("example", { * name: "Example Project", * visibility: "private", * versionControl: "Git", * workItemTemplate: "Agile", * description: "Managed by Pulumi", * }); * const example_project_readers = azuredevops.getGroupOutput({ * projectId: example.id, * name: "Readers", * }); * const example_project_contributors = azuredevops.getGroupOutput({ * projectId: example.id, * name: "Contributors", * }); * const example_project_administrators = azuredevops.getGroupOutput({ * projectId: example.id, * name: "Project administrators", * }); * const example_permissions = new azuredevops.GitPermissions("example-permissions", { * projectId: example.id, * principal: example_project_readers.apply(example_project_readers => example_project_readers.id), * permissions: { * CreateRepository: "Deny", * DeleteRepository: "Deny", * RenameRepository: "NotSet", * }, * }); * const exampleGit = new azuredevops.Git("example", { * projectId: example.id, * name: "TestRepo", * defaultBranch: "refs/heads/master", * initialization: { * initType: "Clean", * }, * }); * const example_repo_permissions = new azuredevops.GitPermissions("example-repo-permissions", { * projectId: exampleGit.projectId, * repositoryId: exampleGit.id, * principal: example_project_administrators.apply(example_project_administrators => example_project_administrators.id), * permissions: { * RemoveOthersLocks: "Allow", * ManagePermissions: "Deny", * CreateTag: "Deny", * CreateBranch: "NotSet", * }, * }); * const example_branch_permissions = new azuredevops.GitPermissions("example-branch-permissions", { * projectId: exampleGit.projectId, * repositoryId: exampleGit.id, * branchName: "master", * principal: example_project_contributors.apply(example_project_contributors => example_project_contributors.id), * permissions: { * RemoveOthersLocks: "Allow", * ForcePush: "Deny", * }, * }); * ``` * * ## Relevant Links * * * [Azure DevOps Service REST API 7.0 - Security](https://docs.microsoft.com/en-us/rest/api/azure/devops/security/?view=azure-devops-rest-7.0) * * ## PAT Permissions Required * * - **Project & Team**: vso.security_manage - Grants the ability to read, write, and manage security permissions. * * ## Import * * The resource does not support import. */ class GitPermissions extends pulumi.CustomResource { /** * Get an existing GitPermissions resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, state, opts) { return new GitPermissions(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of GitPermissions. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === GitPermissions.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["branchName"] = state ? state.branchName : undefined; resourceInputs["permissions"] = state ? state.permissions : undefined; resourceInputs["principal"] = state ? state.principal : undefined; resourceInputs["projectId"] = state ? state.projectId : undefined; resourceInputs["replace"] = state ? state.replace : undefined; resourceInputs["repositoryId"] = state ? state.repositoryId : undefined; } else { const args = argsOrState; if ((!args || args.permissions === undefined) && !opts.urn) { throw new Error("Missing required property 'permissions'"); } if ((!args || args.principal === undefined) && !opts.urn) { throw new Error("Missing required property 'principal'"); } if ((!args || args.projectId === undefined) && !opts.urn) { throw new Error("Missing required property 'projectId'"); } resourceInputs["branchName"] = args ? args.branchName : undefined; resourceInputs["permissions"] = args ? args.permissions : undefined; resourceInputs["principal"] = args ? args.principal : undefined; resourceInputs["projectId"] = args ? args.projectId : undefined; resourceInputs["replace"] = args ? args.replace : undefined; resourceInputs["repositoryId"] = args ? args.repositoryId : undefined; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(GitPermissions.__pulumiType, name, resourceInputs, opts); } } exports.GitPermissions = GitPermissions; /** @internal */ GitPermissions.__pulumiType = 'azuredevops:index/gitPermissions:GitPermissions'; //# sourceMappingURL=gitPermissions.js.map