All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.gitlab.kotlin.BranchProtectionArgs.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 8.4.2.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gitlab.kotlin

import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.gitlab.BranchProtectionArgs.builder
import com.pulumi.gitlab.kotlin.inputs.BranchProtectionAllowedToMergeArgs
import com.pulumi.gitlab.kotlin.inputs.BranchProtectionAllowedToMergeArgsBuilder
import com.pulumi.gitlab.kotlin.inputs.BranchProtectionAllowedToPushArgs
import com.pulumi.gitlab.kotlin.inputs.BranchProtectionAllowedToPushArgsBuilder
import com.pulumi.gitlab.kotlin.inputs.BranchProtectionAllowedToUnprotectArgs
import com.pulumi.gitlab.kotlin.inputs.BranchProtectionAllowedToUnprotectArgsBuilder
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.applySuspend
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.jvm.JvmName

/**
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gitlab from "@pulumi/gitlab";
 * const branchProtect = new gitlab.BranchProtection("BranchProtect", {
 *     project: "12345",
 *     branch: "BranchProtected",
 *     pushAccessLevel: "developer",
 *     mergeAccessLevel: "developer",
 *     unprotectAccessLevel: "developer",
 *     allowForcePush: true,
 *     codeOwnerApprovalRequired: true,
 *     allowedToPushes: [
 *         {
 *             userId: 5,
 *         },
 *         {
 *             userId: 521,
 *         },
 *     ],
 *     allowedToMerges: [
 *         {
 *             userId: 15,
 *         },
 *         {
 *             userId: 37,
 *         },
 *     ],
 *     allowedToUnprotects: [
 *         {
 *             userId: 15,
 *         },
 *         {
 *             groupId: 42,
 *         },
 *     ],
 * });
 * // Example using dynamic block
 * const main = new gitlab.BranchProtection("main", {
 *     allowedToPushes: [
 *         50,
 *         55,
 *         60,
 *     ].map((v, k) => ({key: k, value: v})).map(entry => ({
 *         userId: entry.value,
 *     })),
 *     project: "12345",
 *     branch: "main",
 *     pushAccessLevel: "maintainer",
 *     mergeAccessLevel: "maintainer",
 *     unprotectAccessLevel: "maintainer",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gitlab as gitlab
 * branch_protect = gitlab.BranchProtection("BranchProtect",
 *     project="12345",
 *     branch="BranchProtected",
 *     push_access_level="developer",
 *     merge_access_level="developer",
 *     unprotect_access_level="developer",
 *     allow_force_push=True,
 *     code_owner_approval_required=True,
 *     allowed_to_pushes=[
 *         {
 *             "user_id": 5,
 *         },
 *         {
 *             "user_id": 521,
 *         },
 *     ],
 *     allowed_to_merges=[
 *         {
 *             "user_id": 15,
 *         },
 *         {
 *             "user_id": 37,
 *         },
 *     ],
 *     allowed_to_unprotects=[
 *         {
 *             "user_id": 15,
 *         },
 *         {
 *             "group_id": 42,
 *         },
 *     ])
 * # Example using dynamic block
 * main = gitlab.BranchProtection("main",
 *     allowed_to_pushes=[{
 *         "user_id": entry["value"],
 *     } for entry in [{"key": k, "value": v} for k, v in [
 *         50,
 *         55,
 *         60,
 *     ]]],
 *     project="12345",
 *     branch="main",
 *     push_access_level="maintainer",
 *     merge_access_level="maintainer",
 *     unprotect_access_level="maintainer")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using GitLab = Pulumi.GitLab;
 * return await Deployment.RunAsync(() =>
 * {
 *     var branchProtect = new GitLab.BranchProtection("BranchProtect", new()
 *     {
 *         Project = "12345",
 *         Branch = "BranchProtected",
 *         PushAccessLevel = "developer",
 *         MergeAccessLevel = "developer",
 *         UnprotectAccessLevel = "developer",
 *         AllowForcePush = true,
 *         CodeOwnerApprovalRequired = true,
 *         AllowedToPushes = new[]
 *         {
 *             new GitLab.Inputs.BranchProtectionAllowedToPushArgs
 *             {
 *                 UserId = 5,
 *             },
 *             new GitLab.Inputs.BranchProtectionAllowedToPushArgs
 *             {
 *                 UserId = 521,
 *             },
 *         },
 *         AllowedToMerges = new[]
 *         {
 *             new GitLab.Inputs.BranchProtectionAllowedToMergeArgs
 *             {
 *                 UserId = 15,
 *             },
 *             new GitLab.Inputs.BranchProtectionAllowedToMergeArgs
 *             {
 *                 UserId = 37,
 *             },
 *         },
 *         AllowedToUnprotects = new[]
 *         {
 *             new GitLab.Inputs.BranchProtectionAllowedToUnprotectArgs
 *             {
 *                 UserId = 15,
 *             },
 *             new GitLab.Inputs.BranchProtectionAllowedToUnprotectArgs
 *             {
 *                 GroupId = 42,
 *             },
 *         },
 *     });
 *     // Example using dynamic block
 *     var main = new GitLab.BranchProtection("main", new()
 *     {
 *         AllowedToPushes = new[]
 *         {
 *             50,
 *             55,
 *             60,
 *         }.Select((v, k) => new { Key = k, Value = v }).Select(entry =>
 *         {
 *             return new GitLab.Inputs.BranchProtectionAllowedToPushArgs
 *             {
 *                 UserId = entry.Value,
 *             };
 *         }).ToList(),
 *         Project = "12345",
 *         Branch = "main",
 *         PushAccessLevel = "maintainer",
 *         MergeAccessLevel = "maintainer",
 *         UnprotectAccessLevel = "maintainer",
 *     });
 * });
 * ```
 * 
 * ## Import
 * Starting in Terraform v1.5.0 you can use an import block to import `gitlab_branch_protection`. For example:
 * terraform
 * import {
 *   to = gitlab_branch_protection.example
 *   id = "see CLI command below for ID"
 * }
 * Import using the CLI is supported using the following syntax:
 * Gitlab protected branches can be imported with a key composed of `:`, e.g.
 * ```sh
 * $ pulumi import gitlab:index/branchProtection:BranchProtection BranchProtect "12345:main"
 * ```
 * @property allowForcePush Can be set to true to allow users with push access to force push.
 * @property allowedToMerges Array of access levels and user(s)/group(s) allowed to merge to protected branch.
 * @property allowedToPushes Array of access levels and user(s)/group(s) allowed to push to protected branch.
 * @property allowedToUnprotects Array of access levels and user(s)/group(s) allowed to unprotect push to protected branch.
 * @property branch Name of the branch.
 * @property codeOwnerApprovalRequired Can be set to true to require code owner approval before merging. Only available for Premium and Ultimate instances.
 * @property mergeAccessLevel Access levels allowed to merge. Valid values are: `no one`, `developer`, `maintainer`.
 * @property project The id of the project.
 * @property pushAccessLevel Access levels allowed to push. Valid values are: `no one`, `developer`, `maintainer`.
 * @property unprotectAccessLevel Access levels allowed to unprotect. Valid values are: `developer`, `maintainer`, `admin`.
 */
public data class BranchProtectionArgs(
    public val allowForcePush: Output? = null,
    public val allowedToMerges: Output>? = null,
    public val allowedToPushes: Output>? = null,
    public val allowedToUnprotects: Output>? = null,
    public val branch: Output? = null,
    public val codeOwnerApprovalRequired: Output? = null,
    public val mergeAccessLevel: Output? = null,
    public val project: Output? = null,
    public val pushAccessLevel: Output? = null,
    public val unprotectAccessLevel: Output? = null,
) : ConvertibleToJava {
    override fun toJava(): com.pulumi.gitlab.BranchProtectionArgs =
        com.pulumi.gitlab.BranchProtectionArgs.builder()
            .allowForcePush(allowForcePush?.applyValue({ args0 -> args0 }))
            .allowedToMerges(
                allowedToMerges?.applyValue({ args0 ->
                    args0.map({ args0 ->
                        args0.let({ args0 ->
                            args0.toJava()
                        })
                    })
                }),
            )
            .allowedToPushes(
                allowedToPushes?.applyValue({ args0 ->
                    args0.map({ args0 ->
                        args0.let({ args0 ->
                            args0.toJava()
                        })
                    })
                }),
            )
            .allowedToUnprotects(
                allowedToUnprotects?.applyValue({ args0 ->
                    args0.map({ args0 ->
                        args0.let({ args0 -> args0.toJava() })
                    })
                }),
            )
            .branch(branch?.applyValue({ args0 -> args0 }))
            .codeOwnerApprovalRequired(codeOwnerApprovalRequired?.applyValue({ args0 -> args0 }))
            .mergeAccessLevel(mergeAccessLevel?.applyValue({ args0 -> args0 }))
            .project(project?.applyValue({ args0 -> args0 }))
            .pushAccessLevel(pushAccessLevel?.applyValue({ args0 -> args0 }))
            .unprotectAccessLevel(unprotectAccessLevel?.applyValue({ args0 -> args0 })).build()
}

/**
 * Builder for [BranchProtectionArgs].
 */
@PulumiTagMarker
public class BranchProtectionArgsBuilder internal constructor() {
    private var allowForcePush: Output? = null

    private var allowedToMerges: Output>? = null

    private var allowedToPushes: Output>? = null

    private var allowedToUnprotects: Output>? = null

    private var branch: Output? = null

    private var codeOwnerApprovalRequired: Output? = null

    private var mergeAccessLevel: Output? = null

    private var project: Output? = null

    private var pushAccessLevel: Output? = null

    private var unprotectAccessLevel: Output? = null

    /**
     * @param value Can be set to true to allow users with push access to force push.
     */
    @JvmName("sqsektyngopkqxtg")
    public suspend fun allowForcePush(`value`: Output) {
        this.allowForcePush = value
    }

    /**
     * @param value Array of access levels and user(s)/group(s) allowed to merge to protected branch.
     */
    @JvmName("ufbmldmtaofprgdc")
    public suspend fun allowedToMerges(`value`: Output>) {
        this.allowedToMerges = value
    }

    @JvmName("rwcxmohbvvkpphhf")
    public suspend fun allowedToMerges(vararg values: Output) {
        this.allowedToMerges = Output.all(values.asList())
    }

    /**
     * @param values Array of access levels and user(s)/group(s) allowed to merge to protected branch.
     */
    @JvmName("hardvrukybfpupck")
    public suspend fun allowedToMerges(values: List>) {
        this.allowedToMerges = Output.all(values)
    }

    /**
     * @param value Array of access levels and user(s)/group(s) allowed to push to protected branch.
     */
    @JvmName("yaextesatrqkyegh")
    public suspend fun allowedToPushes(`value`: Output>) {
        this.allowedToPushes = value
    }

    @JvmName("ralavypfarartmmu")
    public suspend fun allowedToPushes(vararg values: Output) {
        this.allowedToPushes = Output.all(values.asList())
    }

    /**
     * @param values Array of access levels and user(s)/group(s) allowed to push to protected branch.
     */
    @JvmName("jidhyospnugiimja")
    public suspend fun allowedToPushes(values: List>) {
        this.allowedToPushes = Output.all(values)
    }

    /**
     * @param value Array of access levels and user(s)/group(s) allowed to unprotect push to protected branch.
     */
    @JvmName("aopbrjyclxgvifyk")
    public suspend fun allowedToUnprotects(`value`: Output>) {
        this.allowedToUnprotects = value
    }

    @JvmName("xdtihftkmbyfuosf")
    public suspend fun allowedToUnprotects(vararg values: Output) {
        this.allowedToUnprotects = Output.all(values.asList())
    }

    /**
     * @param values Array of access levels and user(s)/group(s) allowed to unprotect push to protected branch.
     */
    @JvmName("jjkywjtycwqkqpdf")
    public suspend fun allowedToUnprotects(values: List>) {
        this.allowedToUnprotects = Output.all(values)
    }

    /**
     * @param value Name of the branch.
     */
    @JvmName("hmdptsloaacxgwef")
    public suspend fun branch(`value`: Output) {
        this.branch = value
    }

    /**
     * @param value Can be set to true to require code owner approval before merging. Only available for Premium and Ultimate instances.
     */
    @JvmName("rqvcblsdjfhthrub")
    public suspend fun codeOwnerApprovalRequired(`value`: Output) {
        this.codeOwnerApprovalRequired = value
    }

    /**
     * @param value Access levels allowed to merge. Valid values are: `no one`, `developer`, `maintainer`.
     */
    @JvmName("rkuhkgvdyrwltrsd")
    public suspend fun mergeAccessLevel(`value`: Output) {
        this.mergeAccessLevel = value
    }

    /**
     * @param value The id of the project.
     */
    @JvmName("wcytwljceucuuese")
    public suspend fun project(`value`: Output) {
        this.project = value
    }

    /**
     * @param value Access levels allowed to push. Valid values are: `no one`, `developer`, `maintainer`.
     */
    @JvmName("krowyqmwvjiqscyb")
    public suspend fun pushAccessLevel(`value`: Output) {
        this.pushAccessLevel = value
    }

    /**
     * @param value Access levels allowed to unprotect. Valid values are: `developer`, `maintainer`, `admin`.
     */
    @JvmName("gkjhwukehwuaqxil")
    public suspend fun unprotectAccessLevel(`value`: Output) {
        this.unprotectAccessLevel = value
    }

    /**
     * @param value Can be set to true to allow users with push access to force push.
     */
    @JvmName("swvbvwtbgnrtffhv")
    public suspend fun allowForcePush(`value`: Boolean?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.allowForcePush = mapped
    }

    /**
     * @param value Array of access levels and user(s)/group(s) allowed to merge to protected branch.
     */
    @JvmName("uinysqqghqlxmbhv")
    public suspend fun allowedToMerges(`value`: List?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.allowedToMerges = mapped
    }

    /**
     * @param argument Array of access levels and user(s)/group(s) allowed to merge to protected branch.
     */
    @JvmName("bnmtoahafxtlhblx")
    public suspend fun allowedToMerges(argument: List Unit>) {
        val toBeMapped = argument.toList().map {
            BranchProtectionAllowedToMergeArgsBuilder().applySuspend { it() }.build()
        }
        val mapped = of(toBeMapped)
        this.allowedToMerges = mapped
    }

    /**
     * @param argument Array of access levels and user(s)/group(s) allowed to merge to protected branch.
     */
    @JvmName("reofhpdiyjwtjhun")
    public suspend fun allowedToMerges(vararg argument: suspend BranchProtectionAllowedToMergeArgsBuilder.() -> Unit) {
        val toBeMapped = argument.toList().map {
            BranchProtectionAllowedToMergeArgsBuilder().applySuspend { it() }.build()
        }
        val mapped = of(toBeMapped)
        this.allowedToMerges = mapped
    }

    /**
     * @param argument Array of access levels and user(s)/group(s) allowed to merge to protected branch.
     */
    @JvmName("plebegftxdxjjopq")
    public suspend fun allowedToMerges(argument: suspend BranchProtectionAllowedToMergeArgsBuilder.() -> Unit) {
        val toBeMapped = listOf(
            BranchProtectionAllowedToMergeArgsBuilder().applySuspend {
                argument()
            }.build(),
        )
        val mapped = of(toBeMapped)
        this.allowedToMerges = mapped
    }

    /**
     * @param values Array of access levels and user(s)/group(s) allowed to merge to protected branch.
     */
    @JvmName("ttncggfuuoebuxjq")
    public suspend fun allowedToMerges(vararg values: BranchProtectionAllowedToMergeArgs) {
        val toBeMapped = values.toList()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.allowedToMerges = mapped
    }

    /**
     * @param value Array of access levels and user(s)/group(s) allowed to push to protected branch.
     */
    @JvmName("dcgigfounviqyllc")
    public suspend fun allowedToPushes(`value`: List?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.allowedToPushes = mapped
    }

    /**
     * @param argument Array of access levels and user(s)/group(s) allowed to push to protected branch.
     */
    @JvmName("njcxxhjcdyknpqro")
    public suspend fun allowedToPushes(argument: List Unit>) {
        val toBeMapped = argument.toList().map {
            BranchProtectionAllowedToPushArgsBuilder().applySuspend { it() }.build()
        }
        val mapped = of(toBeMapped)
        this.allowedToPushes = mapped
    }

    /**
     * @param argument Array of access levels and user(s)/group(s) allowed to push to protected branch.
     */
    @JvmName("ecsdtelvxquwrjly")
    public suspend fun allowedToPushes(vararg argument: suspend BranchProtectionAllowedToPushArgsBuilder.() -> Unit) {
        val toBeMapped = argument.toList().map {
            BranchProtectionAllowedToPushArgsBuilder().applySuspend { it() }.build()
        }
        val mapped = of(toBeMapped)
        this.allowedToPushes = mapped
    }

    /**
     * @param argument Array of access levels and user(s)/group(s) allowed to push to protected branch.
     */
    @JvmName("qhayffvhufpbhbjw")
    public suspend fun allowedToPushes(argument: suspend BranchProtectionAllowedToPushArgsBuilder.() -> Unit) {
        val toBeMapped = listOf(
            BranchProtectionAllowedToPushArgsBuilder().applySuspend {
                argument()
            }.build(),
        )
        val mapped = of(toBeMapped)
        this.allowedToPushes = mapped
    }

    /**
     * @param values Array of access levels and user(s)/group(s) allowed to push to protected branch.
     */
    @JvmName("rfvvqbnwutcnjaqs")
    public suspend fun allowedToPushes(vararg values: BranchProtectionAllowedToPushArgs) {
        val toBeMapped = values.toList()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.allowedToPushes = mapped
    }

    /**
     * @param value Array of access levels and user(s)/group(s) allowed to unprotect push to protected branch.
     */
    @JvmName("uwgwcnvssamocgys")
    public suspend fun allowedToUnprotects(`value`: List?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.allowedToUnprotects = mapped
    }

    /**
     * @param argument Array of access levels and user(s)/group(s) allowed to unprotect push to protected branch.
     */
    @JvmName("rkiuvhbefstqggui")
    public suspend fun allowedToUnprotects(argument: List Unit>) {
        val toBeMapped = argument.toList().map {
            BranchProtectionAllowedToUnprotectArgsBuilder().applySuspend { it() }.build()
        }
        val mapped = of(toBeMapped)
        this.allowedToUnprotects = mapped
    }

    /**
     * @param argument Array of access levels and user(s)/group(s) allowed to unprotect push to protected branch.
     */
    @JvmName("sgvrkvaeontoupbd")
    public suspend fun allowedToUnprotects(vararg argument: suspend BranchProtectionAllowedToUnprotectArgsBuilder.() -> Unit) {
        val toBeMapped = argument.toList().map {
            BranchProtectionAllowedToUnprotectArgsBuilder().applySuspend { it() }.build()
        }
        val mapped = of(toBeMapped)
        this.allowedToUnprotects = mapped
    }

    /**
     * @param argument Array of access levels and user(s)/group(s) allowed to unprotect push to protected branch.
     */
    @JvmName("wjeexcbaviplpulu")
    public suspend fun allowedToUnprotects(argument: suspend BranchProtectionAllowedToUnprotectArgsBuilder.() -> Unit) {
        val toBeMapped = listOf(
            BranchProtectionAllowedToUnprotectArgsBuilder().applySuspend {
                argument()
            }.build(),
        )
        val mapped = of(toBeMapped)
        this.allowedToUnprotects = mapped
    }

    /**
     * @param values Array of access levels and user(s)/group(s) allowed to unprotect push to protected branch.
     */
    @JvmName("jjgwjfvyvmmgpgxa")
    public suspend fun allowedToUnprotects(vararg values: BranchProtectionAllowedToUnprotectArgs) {
        val toBeMapped = values.toList()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.allowedToUnprotects = mapped
    }

    /**
     * @param value Name of the branch.
     */
    @JvmName("hafgtdhmajdxxyke")
    public suspend fun branch(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.branch = mapped
    }

    /**
     * @param value Can be set to true to require code owner approval before merging. Only available for Premium and Ultimate instances.
     */
    @JvmName("gvwhaffbdqptintl")
    public suspend fun codeOwnerApprovalRequired(`value`: Boolean?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.codeOwnerApprovalRequired = mapped
    }

    /**
     * @param value Access levels allowed to merge. Valid values are: `no one`, `developer`, `maintainer`.
     */
    @JvmName("aedwkaachrhktbpt")
    public suspend fun mergeAccessLevel(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.mergeAccessLevel = mapped
    }

    /**
     * @param value The id of the project.
     */
    @JvmName("exyfjwywfjpnvcvg")
    public suspend fun project(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.project = mapped
    }

    /**
     * @param value Access levels allowed to push. Valid values are: `no one`, `developer`, `maintainer`.
     */
    @JvmName("votouvuemprnnxlf")
    public suspend fun pushAccessLevel(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.pushAccessLevel = mapped
    }

    /**
     * @param value Access levels allowed to unprotect. Valid values are: `developer`, `maintainer`, `admin`.
     */
    @JvmName("mjxdcxkdecjslrtt")
    public suspend fun unprotectAccessLevel(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.unprotectAccessLevel = mapped
    }

    internal fun build(): BranchProtectionArgs = BranchProtectionArgs(
        allowForcePush = allowForcePush,
        allowedToMerges = allowedToMerges,
        allowedToPushes = allowedToPushes,
        allowedToUnprotects = allowedToUnprotects,
        branch = branch,
        codeOwnerApprovalRequired = codeOwnerApprovalRequired,
        mergeAccessLevel = mergeAccessLevel,
        project = project,
        pushAccessLevel = pushAccessLevel,
        unprotectAccessLevel = unprotectAccessLevel,
    )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy