1. Packages
  2. Bitbucket Provider
  3. API Docs
  4. BranchRestriction
bitbucket 2.46.0 published on Monday, Apr 14, 2025 by drfaust92

bitbucket.BranchRestriction

Explore with Pulumi AI

bitbucket logo
bitbucket 2.46.0 published on Monday, Apr 14, 2025 by drfaust92

    Provides a Bitbucket branch restriction resource.

    This allows you for setting up branch restrictions for your repository.

    OAuth2 Scopes: repository:admin

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as bitbucket from "@pulumi/bitbucket";
    
    const master = new bitbucket.BranchRestriction("master", {
        groups: [{
            owner: "my-owner",
            slug: "my-group",
        }],
        kind: "push",
        owner: "myteam",
        pattern: "master",
        repository: "terraform-code",
        users: ["my-bitbucket-username"],
    });
    
    import pulumi
    import pulumi_bitbucket as bitbucket
    
    master = bitbucket.BranchRestriction("master",
        groups=[{
            "owner": "my-owner",
            "slug": "my-group",
        }],
        kind="push",
        owner="myteam",
        pattern="master",
        repository="terraform-code",
        users=["my-bitbucket-username"])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/bitbucket/v2/bitbucket"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := bitbucket.NewBranchRestriction(ctx, "master", &bitbucket.BranchRestrictionArgs{
    			Groups: bitbucket.BranchRestrictionGroupArray{
    				&bitbucket.BranchRestrictionGroupArgs{
    					Owner: pulumi.String("my-owner"),
    					Slug:  pulumi.String("my-group"),
    				},
    			},
    			Kind:       pulumi.String("push"),
    			Owner:      pulumi.String("myteam"),
    			Pattern:    pulumi.String("master"),
    			Repository: pulumi.String("terraform-code"),
    			Users: pulumi.StringArray{
    				pulumi.String("my-bitbucket-username"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Bitbucket = Pulumi.Bitbucket;
    
    return await Deployment.RunAsync(() => 
    {
        var master = new Bitbucket.BranchRestriction("master", new()
        {
            Groups = new[]
            {
                new Bitbucket.Inputs.BranchRestrictionGroupArgs
                {
                    Owner = "my-owner",
                    Slug = "my-group",
                },
            },
            Kind = "push",
            Owner = "myteam",
            Pattern = "master",
            Repository = "terraform-code",
            Users = new[]
            {
                "my-bitbucket-username",
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.bitbucket.BranchRestriction;
    import com.pulumi.bitbucket.BranchRestrictionArgs;
    import com.pulumi.bitbucket.inputs.BranchRestrictionGroupArgs;
    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 master = new BranchRestriction("master", BranchRestrictionArgs.builder()
                .groups(BranchRestrictionGroupArgs.builder()
                    .owner("my-owner")
                    .slug("my-group")
                    .build())
                .kind("push")
                .owner("myteam")
                .pattern("master")
                .repository("terraform-code")
                .users("my-bitbucket-username")
                .build());
    
        }
    }
    
    resources:
      master:
        type: bitbucket:BranchRestriction
        properties:
          groups:
            - owner: my-owner
              slug: my-group
          kind: push
          owner: myteam
          pattern: master
          repository: terraform-code
          users:
            - my-bitbucket-username
    

    Create BranchRestriction Resource

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

    Constructor syntax

    new BranchRestriction(name: string, args: BranchRestrictionArgs, opts?: CustomResourceOptions);
    @overload
    def BranchRestriction(resource_name: str,
                          args: BranchRestrictionArgs,
                          opts: Optional[ResourceOptions] = None)
    
    @overload
    def BranchRestriction(resource_name: str,
                          opts: Optional[ResourceOptions] = None,
                          kind: Optional[str] = None,
                          owner: Optional[str] = None,
                          repository: Optional[str] = None,
                          branch_match_kind: Optional[str] = None,
                          branch_restriction_id: Optional[str] = None,
                          branch_type: Optional[str] = None,
                          groups: Optional[Sequence[BranchRestrictionGroupArgs]] = None,
                          pattern: Optional[str] = None,
                          users: Optional[Sequence[str]] = None,
                          value: Optional[float] = None)
    func NewBranchRestriction(ctx *Context, name string, args BranchRestrictionArgs, opts ...ResourceOption) (*BranchRestriction, error)
    public BranchRestriction(string name, BranchRestrictionArgs args, CustomResourceOptions? opts = null)
    public BranchRestriction(String name, BranchRestrictionArgs args)
    public BranchRestriction(String name, BranchRestrictionArgs args, CustomResourceOptions options)
    
    type: bitbucket:BranchRestriction
    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 BranchRestrictionArgs
    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 BranchRestrictionArgs
    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 BranchRestrictionArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args BranchRestrictionArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args BranchRestrictionArgs
    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 branchRestrictionResource = new Bitbucket.BranchRestriction("branchRestrictionResource", new()
    {
        Kind = "string",
        Owner = "string",
        Repository = "string",
        BranchMatchKind = "string",
        BranchRestrictionId = "string",
        BranchType = "string",
        Groups = new[]
        {
            new Bitbucket.Inputs.BranchRestrictionGroupArgs
            {
                Owner = "string",
                Slug = "string",
            },
        },
        Pattern = "string",
        Users = new[]
        {
            "string",
        },
        Value = 0,
    });
    
    example, err := bitbucket.NewBranchRestriction(ctx, "branchRestrictionResource", &bitbucket.BranchRestrictionArgs{
    	Kind:                pulumi.String("string"),
    	Owner:               pulumi.String("string"),
    	Repository:          pulumi.String("string"),
    	BranchMatchKind:     pulumi.String("string"),
    	BranchRestrictionId: pulumi.String("string"),
    	BranchType:          pulumi.String("string"),
    	Groups: bitbucket.BranchRestrictionGroupArray{
    		&bitbucket.BranchRestrictionGroupArgs{
    			Owner: pulumi.String("string"),
    			Slug:  pulumi.String("string"),
    		},
    	},
    	Pattern: pulumi.String("string"),
    	Users: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	Value: pulumi.Float64(0),
    })
    
    var branchRestrictionResource = new BranchRestriction("branchRestrictionResource", BranchRestrictionArgs.builder()
        .kind("string")
        .owner("string")
        .repository("string")
        .branchMatchKind("string")
        .branchRestrictionId("string")
        .branchType("string")
        .groups(BranchRestrictionGroupArgs.builder()
            .owner("string")
            .slug("string")
            .build())
        .pattern("string")
        .users("string")
        .value(0)
        .build());
    
    branch_restriction_resource = bitbucket.BranchRestriction("branchRestrictionResource",
        kind="string",
        owner="string",
        repository="string",
        branch_match_kind="string",
        branch_restriction_id="string",
        branch_type="string",
        groups=[{
            "owner": "string",
            "slug": "string",
        }],
        pattern="string",
        users=["string"],
        value=0)
    
    const branchRestrictionResource = new bitbucket.BranchRestriction("branchRestrictionResource", {
        kind: "string",
        owner: "string",
        repository: "string",
        branchMatchKind: "string",
        branchRestrictionId: "string",
        branchType: "string",
        groups: [{
            owner: "string",
            slug: "string",
        }],
        pattern: "string",
        users: ["string"],
        value: 0,
    });
    
    type: bitbucket:BranchRestriction
    properties:
        branchMatchKind: string
        branchRestrictionId: string
        branchType: string
        groups:
            - owner: string
              slug: string
        kind: string
        owner: string
        pattern: string
        repository: string
        users:
            - string
        value: 0
    

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

    Kind string
    The type of restriction that is being applied. Valid values can be found in docs.
    Owner string
    The owner of this repository. Can be you or any team you have write access to.
    Repository string
    The name of the repository.
    BranchMatchKind string
    Indicates how the restriction is matched against a branch. The default is glob. Valid values: branching_model, glob.
    BranchRestrictionId string
    BranchType string
    Apply the restriction to branches of this type. Active when branch_match_kind is branching_model. The branch type will be calculated using the branching model configured for the repository. Valid values: feature, bugfix, release, hotfix, development, production.
    Groups List<BranchRestrictionGroup>
    A list of groups to use.
    Pattern string
    Apply the restriction to branches that match this pattern. Active when branch_match_kind is glob. Will be empty when branch_match_kind is branching_model.
    Users List<string>
    A list of users to use.
    Value double
    A value applied to the restriction kind. Currently only applicable to require_passing_builds_to_merge, require_default_reviewer_approvals_to_merge and require_approvals_to_merge.
    Kind string
    The type of restriction that is being applied. Valid values can be found in docs.
    Owner string
    The owner of this repository. Can be you or any team you have write access to.
    Repository string
    The name of the repository.
    BranchMatchKind string
    Indicates how the restriction is matched against a branch. The default is glob. Valid values: branching_model, glob.
    BranchRestrictionId string
    BranchType string
    Apply the restriction to branches of this type. Active when branch_match_kind is branching_model. The branch type will be calculated using the branching model configured for the repository. Valid values: feature, bugfix, release, hotfix, development, production.
    Groups []BranchRestrictionGroupArgs
    A list of groups to use.
    Pattern string
    Apply the restriction to branches that match this pattern. Active when branch_match_kind is glob. Will be empty when branch_match_kind is branching_model.
    Users []string
    A list of users to use.
    Value float64
    A value applied to the restriction kind. Currently only applicable to require_passing_builds_to_merge, require_default_reviewer_approvals_to_merge and require_approvals_to_merge.
    kind String
    The type of restriction that is being applied. Valid values can be found in docs.
    owner String
    The owner of this repository. Can be you or any team you have write access to.
    repository String
    The name of the repository.
    branchMatchKind String
    Indicates how the restriction is matched against a branch. The default is glob. Valid values: branching_model, glob.
    branchRestrictionId String
    branchType String
    Apply the restriction to branches of this type. Active when branch_match_kind is branching_model. The branch type will be calculated using the branching model configured for the repository. Valid values: feature, bugfix, release, hotfix, development, production.
    groups List<BranchRestrictionGroup>
    A list of groups to use.
    pattern String
    Apply the restriction to branches that match this pattern. Active when branch_match_kind is glob. Will be empty when branch_match_kind is branching_model.
    users List<String>
    A list of users to use.
    value Double
    A value applied to the restriction kind. Currently only applicable to require_passing_builds_to_merge, require_default_reviewer_approvals_to_merge and require_approvals_to_merge.
    kind string
    The type of restriction that is being applied. Valid values can be found in docs.
    owner string
    The owner of this repository. Can be you or any team you have write access to.
    repository string
    The name of the repository.
    branchMatchKind string
    Indicates how the restriction is matched against a branch. The default is glob. Valid values: branching_model, glob.
    branchRestrictionId string
    branchType string
    Apply the restriction to branches of this type. Active when branch_match_kind is branching_model. The branch type will be calculated using the branching model configured for the repository. Valid values: feature, bugfix, release, hotfix, development, production.
    groups BranchRestrictionGroup[]
    A list of groups to use.
    pattern string
    Apply the restriction to branches that match this pattern. Active when branch_match_kind is glob. Will be empty when branch_match_kind is branching_model.
    users string[]
    A list of users to use.
    value number
    A value applied to the restriction kind. Currently only applicable to require_passing_builds_to_merge, require_default_reviewer_approvals_to_merge and require_approvals_to_merge.
    kind str
    The type of restriction that is being applied. Valid values can be found in docs.
    owner str
    The owner of this repository. Can be you or any team you have write access to.
    repository str
    The name of the repository.
    branch_match_kind str
    Indicates how the restriction is matched against a branch. The default is glob. Valid values: branching_model, glob.
    branch_restriction_id str
    branch_type str
    Apply the restriction to branches of this type. Active when branch_match_kind is branching_model. The branch type will be calculated using the branching model configured for the repository. Valid values: feature, bugfix, release, hotfix, development, production.
    groups Sequence[BranchRestrictionGroupArgs]
    A list of groups to use.
    pattern str
    Apply the restriction to branches that match this pattern. Active when branch_match_kind is glob. Will be empty when branch_match_kind is branching_model.
    users Sequence[str]
    A list of users to use.
    value float
    A value applied to the restriction kind. Currently only applicable to require_passing_builds_to_merge, require_default_reviewer_approvals_to_merge and require_approvals_to_merge.
    kind String
    The type of restriction that is being applied. Valid values can be found in docs.
    owner String
    The owner of this repository. Can be you or any team you have write access to.
    repository String
    The name of the repository.
    branchMatchKind String
    Indicates how the restriction is matched against a branch. The default is glob. Valid values: branching_model, glob.
    branchRestrictionId String
    branchType String
    Apply the restriction to branches of this type. Active when branch_match_kind is branching_model. The branch type will be calculated using the branching model configured for the repository. Valid values: feature, bugfix, release, hotfix, development, production.
    groups List<Property Map>
    A list of groups to use.
    pattern String
    Apply the restriction to branches that match this pattern. Active when branch_match_kind is glob. Will be empty when branch_match_kind is branching_model.
    users List<String>
    A list of users to use.
    value Number
    A value applied to the restriction kind. Currently only applicable to require_passing_builds_to_merge, require_default_reviewer_approvals_to_merge and require_approvals_to_merge.

    Outputs

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

    Get an existing BranchRestriction 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?: BranchRestrictionState, opts?: CustomResourceOptions): BranchRestriction
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            branch_match_kind: Optional[str] = None,
            branch_restriction_id: Optional[str] = None,
            branch_type: Optional[str] = None,
            groups: Optional[Sequence[BranchRestrictionGroupArgs]] = None,
            kind: Optional[str] = None,
            owner: Optional[str] = None,
            pattern: Optional[str] = None,
            repository: Optional[str] = None,
            users: Optional[Sequence[str]] = None,
            value: Optional[float] = None) -> BranchRestriction
    func GetBranchRestriction(ctx *Context, name string, id IDInput, state *BranchRestrictionState, opts ...ResourceOption) (*BranchRestriction, error)
    public static BranchRestriction Get(string name, Input<string> id, BranchRestrictionState? state, CustomResourceOptions? opts = null)
    public static BranchRestriction get(String name, Output<String> id, BranchRestrictionState state, CustomResourceOptions options)
    resources:  _:    type: bitbucket:BranchRestriction    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:
    BranchMatchKind string
    Indicates how the restriction is matched against a branch. The default is glob. Valid values: branching_model, glob.
    BranchRestrictionId string
    BranchType string
    Apply the restriction to branches of this type. Active when branch_match_kind is branching_model. The branch type will be calculated using the branching model configured for the repository. Valid values: feature, bugfix, release, hotfix, development, production.
    Groups List<BranchRestrictionGroup>
    A list of groups to use.
    Kind string
    The type of restriction that is being applied. Valid values can be found in docs.
    Owner string
    The owner of this repository. Can be you or any team you have write access to.
    Pattern string
    Apply the restriction to branches that match this pattern. Active when branch_match_kind is glob. Will be empty when branch_match_kind is branching_model.
    Repository string
    The name of the repository.
    Users List<string>
    A list of users to use.
    Value double
    A value applied to the restriction kind. Currently only applicable to require_passing_builds_to_merge, require_default_reviewer_approvals_to_merge and require_approvals_to_merge.
    BranchMatchKind string
    Indicates how the restriction is matched against a branch. The default is glob. Valid values: branching_model, glob.
    BranchRestrictionId string
    BranchType string
    Apply the restriction to branches of this type. Active when branch_match_kind is branching_model. The branch type will be calculated using the branching model configured for the repository. Valid values: feature, bugfix, release, hotfix, development, production.
    Groups []BranchRestrictionGroupArgs
    A list of groups to use.
    Kind string
    The type of restriction that is being applied. Valid values can be found in docs.
    Owner string
    The owner of this repository. Can be you or any team you have write access to.
    Pattern string
    Apply the restriction to branches that match this pattern. Active when branch_match_kind is glob. Will be empty when branch_match_kind is branching_model.
    Repository string
    The name of the repository.
    Users []string
    A list of users to use.
    Value float64
    A value applied to the restriction kind. Currently only applicable to require_passing_builds_to_merge, require_default_reviewer_approvals_to_merge and require_approvals_to_merge.
    branchMatchKind String
    Indicates how the restriction is matched against a branch. The default is glob. Valid values: branching_model, glob.
    branchRestrictionId String
    branchType String
    Apply the restriction to branches of this type. Active when branch_match_kind is branching_model. The branch type will be calculated using the branching model configured for the repository. Valid values: feature, bugfix, release, hotfix, development, production.
    groups List<BranchRestrictionGroup>
    A list of groups to use.
    kind String
    The type of restriction that is being applied. Valid values can be found in docs.
    owner String
    The owner of this repository. Can be you or any team you have write access to.
    pattern String
    Apply the restriction to branches that match this pattern. Active when branch_match_kind is glob. Will be empty when branch_match_kind is branching_model.
    repository String
    The name of the repository.
    users List<String>
    A list of users to use.
    value Double
    A value applied to the restriction kind. Currently only applicable to require_passing_builds_to_merge, require_default_reviewer_approvals_to_merge and require_approvals_to_merge.
    branchMatchKind string
    Indicates how the restriction is matched against a branch. The default is glob. Valid values: branching_model, glob.
    branchRestrictionId string
    branchType string
    Apply the restriction to branches of this type. Active when branch_match_kind is branching_model. The branch type will be calculated using the branching model configured for the repository. Valid values: feature, bugfix, release, hotfix, development, production.
    groups BranchRestrictionGroup[]
    A list of groups to use.
    kind string
    The type of restriction that is being applied. Valid values can be found in docs.
    owner string
    The owner of this repository. Can be you or any team you have write access to.
    pattern string
    Apply the restriction to branches that match this pattern. Active when branch_match_kind is glob. Will be empty when branch_match_kind is branching_model.
    repository string
    The name of the repository.
    users string[]
    A list of users to use.
    value number
    A value applied to the restriction kind. Currently only applicable to require_passing_builds_to_merge, require_default_reviewer_approvals_to_merge and require_approvals_to_merge.
    branch_match_kind str
    Indicates how the restriction is matched against a branch. The default is glob. Valid values: branching_model, glob.
    branch_restriction_id str
    branch_type str
    Apply the restriction to branches of this type. Active when branch_match_kind is branching_model. The branch type will be calculated using the branching model configured for the repository. Valid values: feature, bugfix, release, hotfix, development, production.
    groups Sequence[BranchRestrictionGroupArgs]
    A list of groups to use.
    kind str
    The type of restriction that is being applied. Valid values can be found in docs.
    owner str
    The owner of this repository. Can be you or any team you have write access to.
    pattern str
    Apply the restriction to branches that match this pattern. Active when branch_match_kind is glob. Will be empty when branch_match_kind is branching_model.
    repository str
    The name of the repository.
    users Sequence[str]
    A list of users to use.
    value float
    A value applied to the restriction kind. Currently only applicable to require_passing_builds_to_merge, require_default_reviewer_approvals_to_merge and require_approvals_to_merge.
    branchMatchKind String
    Indicates how the restriction is matched against a branch. The default is glob. Valid values: branching_model, glob.
    branchRestrictionId String
    branchType String
    Apply the restriction to branches of this type. Active when branch_match_kind is branching_model. The branch type will be calculated using the branching model configured for the repository. Valid values: feature, bugfix, release, hotfix, development, production.
    groups List<Property Map>
    A list of groups to use.
    kind String
    The type of restriction that is being applied. Valid values can be found in docs.
    owner String
    The owner of this repository. Can be you or any team you have write access to.
    pattern String
    Apply the restriction to branches that match this pattern. Active when branch_match_kind is glob. Will be empty when branch_match_kind is branching_model.
    repository String
    The name of the repository.
    users List<String>
    A list of users to use.
    value Number
    A value applied to the restriction kind. Currently only applicable to require_passing_builds_to_merge, require_default_reviewer_approvals_to_merge and require_approvals_to_merge.

    Supporting Types

    BranchRestrictionGroup, BranchRestrictionGroupArgs

    Owner string
    The owner of this repository. Can be you or any team you have write access to.
    Slug string
    Owner string
    The owner of this repository. Can be you or any team you have write access to.
    Slug string
    owner String
    The owner of this repository. Can be you or any team you have write access to.
    slug String
    owner string
    The owner of this repository. Can be you or any team you have write access to.
    slug string
    owner str
    The owner of this repository. Can be you or any team you have write access to.
    slug str
    owner String
    The owner of this repository. Can be you or any team you have write access to.
    slug String

    Import

    Branch Restrictions can be imported using their owner/repo-name/branch-restriction-id ID, e.g.

    $ pulumi import bitbucket:index/branchRestriction:BranchRestriction example my-account/my-repo/branch-rest-id
    

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

    Package Details

    Repository
    bitbucket drfaust92/terraform-provider-bitbucket
    License
    Notes
    This Pulumi package is based on the bitbucket Terraform Provider.
    bitbucket logo
    bitbucket 2.46.0 published on Monday, Apr 14, 2025 by drfaust92