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
 * 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("cmmwwgejncsnwkqk")
    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("fupsdxkgseigewry")
    public suspend fun allowedToMerges(`value`: Output>) {
        this.allowedToMerges = value
    }

    @JvmName("csaaflopmjussduy")
    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("ranqghjfdsrgwpyt")
    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("hbfduofdwlvsmvrx")
    public suspend fun allowedToPushes(`value`: Output>) {
        this.allowedToPushes = value
    }

    @JvmName("pgcircruuaaaxxam")
    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("wgkegqsmkxnpsbya")
    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("mgnllmldmmiyctlr")
    public suspend fun allowedToUnprotects(`value`: Output>) {
        this.allowedToUnprotects = value
    }

    @JvmName("doettjqyloiolahc")
    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("kimeasucshbhnrwm")
    public suspend fun allowedToUnprotects(values: List>) {
        this.allowedToUnprotects = Output.all(values)
    }

    /**
     * @param value Name of the branch.
     */
    @JvmName("luhavblluwehelqt")
    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("vigfgurfaucahplq")
    public suspend fun codeOwnerApprovalRequired(`value`: Output) {
        this.codeOwnerApprovalRequired = value
    }

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

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

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

    /**
     * @param value Access levels allowed to unprotect. Valid values are: `developer`, `maintainer`, `admin`.
     */
    @JvmName("mduawxbmwwugrndd")
    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("vlectxjvbrjglfuh")
    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("tbtiycsdmufijpfa")
    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("critasqpwmfuispx")
    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("uxlnvutwogxcedxm")
    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("bwuxaqcpguyvpbjp")
    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("skcfuvwjpuyxbmsu")
    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("qcgxffodqxbfhrhy")
    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("qhskuqioesnxolnr")
    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("gmsmcqpmpyjacnlo")
    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("lyqlecstwyplduht")
    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("gdauulffarkoaahm")
    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("jhrgnllqabhpnrvi")
    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("eonuuofexcdinkwe")
    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("hechcgmylytdyokc")
    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("wabiiigofbhblltg")
    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("osmbortlbatheifm")
    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("kbsfhqtsospfngil")
    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("dkkbvaegglioosda")
    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("xpjwmisgcpacocwb")
    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("snjtbxbflryngfto")
    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("prerxqmnkiwvrkpp")
    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("bfqakcndruubmxai")
    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