1. Packages
  2. GitHub
  3. API Docs
  4. RepositoryCollaborators
GitHub v6.1.0 published on Monday, Mar 11, 2024 by Pulumi

github.RepositoryCollaborators

Explore with Pulumi AI

github logo
GitHub v6.1.0 published on Monday, Mar 11, 2024 by Pulumi

    Provides a GitHub repository collaborators resource.

    Note: github.RepositoryCollaborators cannot be used in conjunction with github.RepositoryCollaborator and github.TeamRepository or they will fight over what your policy should be.

    This resource allows you to manage all collaborators for repositories in your organization or personal account. For organization repositories, collaborators can have explicit (and differing levels of) read, write, or administrator access to specific repositories, without giving the user full organization membership. For personal repositories, collaborators can only be granted write (implicitly includes read) permission.

    When applied, an invitation will be sent to the user to become a collaborators on a repository. When destroyed, either the invitation will be cancelled or the collaborators will be removed from the repository.

    This resource is authoritative. For adding a collaborator to a repo in a non-authoritative manner, use github.RepositoryCollaborator instead.

    Further documentation on GitHub collaborators:

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as github from "@pulumi/github";
    
    // Add collaborators to a repository
    const someTeam = new github.Team("someTeam", {description: "Some cool team"});
    const someRepo = new github.Repository("someRepo", {});
    const someRepoCollaborators = new github.RepositoryCollaborators("someRepoCollaborators", {
        repository: someRepo.name,
        users: [{
            permission: "admin",
            username: "SomeUser",
        }],
        teams: [{
            permission: "pull",
            teamId: someTeam.slug,
        }],
    });
    
    import pulumi
    import pulumi_github as github
    
    # Add collaborators to a repository
    some_team = github.Team("someTeam", description="Some cool team")
    some_repo = github.Repository("someRepo")
    some_repo_collaborators = github.RepositoryCollaborators("someRepoCollaborators",
        repository=some_repo.name,
        users=[github.RepositoryCollaboratorsUserArgs(
            permission="admin",
            username="SomeUser",
        )],
        teams=[github.RepositoryCollaboratorsTeamArgs(
            permission="pull",
            team_id=some_team.slug,
        )])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-github/sdk/v6/go/github"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// Add collaborators to a repository
    		someTeam, err := github.NewTeam(ctx, "someTeam", &github.TeamArgs{
    			Description: pulumi.String("Some cool team"),
    		})
    		if err != nil {
    			return err
    		}
    		someRepo, err := github.NewRepository(ctx, "someRepo", nil)
    		if err != nil {
    			return err
    		}
    		_, err = github.NewRepositoryCollaborators(ctx, "someRepoCollaborators", &github.RepositoryCollaboratorsArgs{
    			Repository: someRepo.Name,
    			Users: github.RepositoryCollaboratorsUserArray{
    				&github.RepositoryCollaboratorsUserArgs{
    					Permission: pulumi.String("admin"),
    					Username:   pulumi.String("SomeUser"),
    				},
    			},
    			Teams: github.RepositoryCollaboratorsTeamArray{
    				&github.RepositoryCollaboratorsTeamArgs{
    					Permission: pulumi.String("pull"),
    					TeamId:     someTeam.Slug,
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Github = Pulumi.Github;
    
    return await Deployment.RunAsync(() => 
    {
        // Add collaborators to a repository
        var someTeam = new Github.Team("someTeam", new()
        {
            Description = "Some cool team",
        });
    
        var someRepo = new Github.Repository("someRepo");
    
        var someRepoCollaborators = new Github.RepositoryCollaborators("someRepoCollaborators", new()
        {
            Repository = someRepo.Name,
            Users = new[]
            {
                new Github.Inputs.RepositoryCollaboratorsUserArgs
                {
                    Permission = "admin",
                    Username = "SomeUser",
                },
            },
            Teams = new[]
            {
                new Github.Inputs.RepositoryCollaboratorsTeamArgs
                {
                    Permission = "pull",
                    TeamId = someTeam.Slug,
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.github.Team;
    import com.pulumi.github.TeamArgs;
    import com.pulumi.github.Repository;
    import com.pulumi.github.RepositoryCollaborators;
    import com.pulumi.github.RepositoryCollaboratorsArgs;
    import com.pulumi.github.inputs.RepositoryCollaboratorsUserArgs;
    import com.pulumi.github.inputs.RepositoryCollaboratorsTeamArgs;
    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 someTeam = new Team("someTeam", TeamArgs.builder()        
                .description("Some cool team")
                .build());
    
            var someRepo = new Repository("someRepo");
    
            var someRepoCollaborators = new RepositoryCollaborators("someRepoCollaborators", RepositoryCollaboratorsArgs.builder()        
                .repository(someRepo.name())
                .users(RepositoryCollaboratorsUserArgs.builder()
                    .permission("admin")
                    .username("SomeUser")
                    .build())
                .teams(RepositoryCollaboratorsTeamArgs.builder()
                    .permission("pull")
                    .teamId(someTeam.slug())
                    .build())
                .build());
    
        }
    }
    
    resources:
      # Add collaborators to a repository
      someTeam:
        type: github:Team
        properties:
          description: Some cool team
      someRepo:
        type: github:Repository
      someRepoCollaborators:
        type: github:RepositoryCollaborators
        properties:
          repository: ${someRepo.name}
          users:
            - permission: admin
              username: SomeUser
          teams:
            - permission: pull
              teamId: ${someTeam.slug}
    

    Create RepositoryCollaborators Resource

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

    Constructor syntax

    new RepositoryCollaborators(name: string, args: RepositoryCollaboratorsArgs, opts?: CustomResourceOptions);
    @overload
    def RepositoryCollaborators(resource_name: str,
                                args: RepositoryCollaboratorsArgs,
                                opts: Optional[ResourceOptions] = None)
    
    @overload
    def RepositoryCollaborators(resource_name: str,
                                opts: Optional[ResourceOptions] = None,
                                repository: Optional[str] = None,
                                teams: Optional[Sequence[RepositoryCollaboratorsTeamArgs]] = None,
                                users: Optional[Sequence[RepositoryCollaboratorsUserArgs]] = None)
    func NewRepositoryCollaborators(ctx *Context, name string, args RepositoryCollaboratorsArgs, opts ...ResourceOption) (*RepositoryCollaborators, error)
    public RepositoryCollaborators(string name, RepositoryCollaboratorsArgs args, CustomResourceOptions? opts = null)
    public RepositoryCollaborators(String name, RepositoryCollaboratorsArgs args)
    public RepositoryCollaborators(String name, RepositoryCollaboratorsArgs args, CustomResourceOptions options)
    
    type: github:RepositoryCollaborators
    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 RepositoryCollaboratorsArgs
    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 RepositoryCollaboratorsArgs
    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 RepositoryCollaboratorsArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args RepositoryCollaboratorsArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args RepositoryCollaboratorsArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Example

    The following reference example uses placeholder values for all input properties.

    var repositoryCollaboratorsResource = new Github.RepositoryCollaborators("repositoryCollaboratorsResource", new()
    {
        Repository = "string",
        Teams = new[]
        {
            new Github.Inputs.RepositoryCollaboratorsTeamArgs
            {
                TeamId = "string",
                Permission = "string",
            },
        },
        Users = new[]
        {
            new Github.Inputs.RepositoryCollaboratorsUserArgs
            {
                Username = "string",
                Permission = "string",
            },
        },
    });
    
    example, err := github.NewRepositoryCollaborators(ctx, "repositoryCollaboratorsResource", &github.RepositoryCollaboratorsArgs{
    	Repository: pulumi.String("string"),
    	Teams: github.RepositoryCollaboratorsTeamArray{
    		&github.RepositoryCollaboratorsTeamArgs{
    			TeamId:     pulumi.String("string"),
    			Permission: pulumi.String("string"),
    		},
    	},
    	Users: github.RepositoryCollaboratorsUserArray{
    		&github.RepositoryCollaboratorsUserArgs{
    			Username:   pulumi.String("string"),
    			Permission: pulumi.String("string"),
    		},
    	},
    })
    
    var repositoryCollaboratorsResource = new RepositoryCollaborators("repositoryCollaboratorsResource", RepositoryCollaboratorsArgs.builder()        
        .repository("string")
        .teams(RepositoryCollaboratorsTeamArgs.builder()
            .teamId("string")
            .permission("string")
            .build())
        .users(RepositoryCollaboratorsUserArgs.builder()
            .username("string")
            .permission("string")
            .build())
        .build());
    
    repository_collaborators_resource = github.RepositoryCollaborators("repositoryCollaboratorsResource",
        repository="string",
        teams=[github.RepositoryCollaboratorsTeamArgs(
            team_id="string",
            permission="string",
        )],
        users=[github.RepositoryCollaboratorsUserArgs(
            username="string",
            permission="string",
        )])
    
    const repositoryCollaboratorsResource = new github.RepositoryCollaborators("repositoryCollaboratorsResource", {
        repository: "string",
        teams: [{
            teamId: "string",
            permission: "string",
        }],
        users: [{
            username: "string",
            permission: "string",
        }],
    });
    
    type: github:RepositoryCollaborators
    properties:
        repository: string
        teams:
            - permission: string
              teamId: string
        users:
            - permission: string
              username: string
    

    RepositoryCollaborators Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The RepositoryCollaborators resource accepts the following input properties:

    repository string
    The GitHub repository
    teams RepositoryCollaboratorsTeam[]
    List of teams
    users RepositoryCollaboratorsUser[]
    List of users
    repository String
    The GitHub repository
    teams List<Property Map>
    List of teams
    users List<Property Map>
    List of users

    Outputs

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

    Id string
    The provider-assigned unique ID for this managed resource.
    InvitationIds Dictionary<string, string>
    Map of usernames to invitation ID for any users added as part of creation of this resource to be used in github.UserInvitationAccepter.
    Id string
    The provider-assigned unique ID for this managed resource.
    InvitationIds map[string]string
    Map of usernames to invitation ID for any users added as part of creation of this resource to be used in github.UserInvitationAccepter.
    id String
    The provider-assigned unique ID for this managed resource.
    invitationIds Map<String,String>
    Map of usernames to invitation ID for any users added as part of creation of this resource to be used in github.UserInvitationAccepter.
    id string
    The provider-assigned unique ID for this managed resource.
    invitationIds {[key: string]: string}
    Map of usernames to invitation ID for any users added as part of creation of this resource to be used in github.UserInvitationAccepter.
    id str
    The provider-assigned unique ID for this managed resource.
    invitation_ids Mapping[str, str]
    Map of usernames to invitation ID for any users added as part of creation of this resource to be used in github.UserInvitationAccepter.
    id String
    The provider-assigned unique ID for this managed resource.
    invitationIds Map<String>
    Map of usernames to invitation ID for any users added as part of creation of this resource to be used in github.UserInvitationAccepter.

    Look up Existing RepositoryCollaborators Resource

    Get an existing RepositoryCollaborators 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?: RepositoryCollaboratorsState, opts?: CustomResourceOptions): RepositoryCollaborators
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            invitation_ids: Optional[Mapping[str, str]] = None,
            repository: Optional[str] = None,
            teams: Optional[Sequence[RepositoryCollaboratorsTeamArgs]] = None,
            users: Optional[Sequence[RepositoryCollaboratorsUserArgs]] = None) -> RepositoryCollaborators
    func GetRepositoryCollaborators(ctx *Context, name string, id IDInput, state *RepositoryCollaboratorsState, opts ...ResourceOption) (*RepositoryCollaborators, error)
    public static RepositoryCollaborators Get(string name, Input<string> id, RepositoryCollaboratorsState? state, CustomResourceOptions? opts = null)
    public static RepositoryCollaborators get(String name, Output<String> id, RepositoryCollaboratorsState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    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:
    InvitationIds Dictionary<string, string>
    Map of usernames to invitation ID for any users added as part of creation of this resource to be used in github.UserInvitationAccepter.
    Repository string
    The GitHub repository
    Teams List<RepositoryCollaboratorsTeam>
    List of teams
    Users List<RepositoryCollaboratorsUser>
    List of users
    InvitationIds map[string]string
    Map of usernames to invitation ID for any users added as part of creation of this resource to be used in github.UserInvitationAccepter.
    Repository string
    The GitHub repository
    Teams []RepositoryCollaboratorsTeamArgs
    List of teams
    Users []RepositoryCollaboratorsUserArgs
    List of users
    invitationIds Map<String,String>
    Map of usernames to invitation ID for any users added as part of creation of this resource to be used in github.UserInvitationAccepter.
    repository String
    The GitHub repository
    teams List<RepositoryCollaboratorsTeam>
    List of teams
    users List<RepositoryCollaboratorsUser>
    List of users
    invitationIds {[key: string]: string}
    Map of usernames to invitation ID for any users added as part of creation of this resource to be used in github.UserInvitationAccepter.
    repository string
    The GitHub repository
    teams RepositoryCollaboratorsTeam[]
    List of teams
    users RepositoryCollaboratorsUser[]
    List of users
    invitation_ids Mapping[str, str]
    Map of usernames to invitation ID for any users added as part of creation of this resource to be used in github.UserInvitationAccepter.
    repository str
    The GitHub repository
    teams Sequence[RepositoryCollaboratorsTeamArgs]
    List of teams
    users Sequence[RepositoryCollaboratorsUserArgs]
    List of users
    invitationIds Map<String>
    Map of usernames to invitation ID for any users added as part of creation of this resource to be used in github.UserInvitationAccepter.
    repository String
    The GitHub repository
    teams List<Property Map>
    List of teams
    users List<Property Map>
    List of users

    Supporting Types

    RepositoryCollaboratorsTeam, RepositoryCollaboratorsTeamArgs

    TeamId string
    The GitHub team id or the GitHub team slug
    Permission string
    The permission of the outside collaborators for the repository. Must be one of pull, triage, push, maintain, admin or the name of an existing custom repository role within the organisation. Defaults to pull. Must be push for personal repositories. Defaults to push.
    TeamId string
    The GitHub team id or the GitHub team slug
    Permission string
    The permission of the outside collaborators for the repository. Must be one of pull, triage, push, maintain, admin or the name of an existing custom repository role within the organisation. Defaults to pull. Must be push for personal repositories. Defaults to push.
    teamId String
    The GitHub team id or the GitHub team slug
    permission String
    The permission of the outside collaborators for the repository. Must be one of pull, triage, push, maintain, admin or the name of an existing custom repository role within the organisation. Defaults to pull. Must be push for personal repositories. Defaults to push.
    teamId string
    The GitHub team id or the GitHub team slug
    permission string
    The permission of the outside collaborators for the repository. Must be one of pull, triage, push, maintain, admin or the name of an existing custom repository role within the organisation. Defaults to pull. Must be push for personal repositories. Defaults to push.
    team_id str
    The GitHub team id or the GitHub team slug
    permission str
    The permission of the outside collaborators for the repository. Must be one of pull, triage, push, maintain, admin or the name of an existing custom repository role within the organisation. Defaults to pull. Must be push for personal repositories. Defaults to push.
    teamId String
    The GitHub team id or the GitHub team slug
    permission String
    The permission of the outside collaborators for the repository. Must be one of pull, triage, push, maintain, admin or the name of an existing custom repository role within the organisation. Defaults to pull. Must be push for personal repositories. Defaults to push.

    RepositoryCollaboratorsUser, RepositoryCollaboratorsUserArgs

    Username string
    The user to add to the repository as a collaborator.
    Permission string
    The permission of the outside collaborators for the repository. Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. Must be push for personal repositories. Defaults to push.
    Username string
    The user to add to the repository as a collaborator.
    Permission string
    The permission of the outside collaborators for the repository. Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. Must be push for personal repositories. Defaults to push.
    username String
    The user to add to the repository as a collaborator.
    permission String
    The permission of the outside collaborators for the repository. Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. Must be push for personal repositories. Defaults to push.
    username string
    The user to add to the repository as a collaborator.
    permission string
    The permission of the outside collaborators for the repository. Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. Must be push for personal repositories. Defaults to push.
    username str
    The user to add to the repository as a collaborator.
    permission str
    The permission of the outside collaborators for the repository. Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. Must be push for personal repositories. Defaults to push.
    username String
    The user to add to the repository as a collaborator.
    permission String
    The permission of the outside collaborators for the repository. Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. Must be push for personal repositories. Defaults to push.

    Import

    GitHub Repository Collaborators can be imported using the name name, e.g.

    $ pulumi import github:index/repositoryCollaborators:RepositoryCollaborators collaborators terraform
    

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

    Package Details

    Repository
    GitHub pulumi/pulumi-github
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the github Terraform Provider.
    github logo
    GitHub v6.1.0 published on Monday, Mar 11, 2024 by Pulumi