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

com.pulumi.gcp.securesourcemanager.kotlin.BranchRule.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.20.1.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gcp.securesourcemanager.kotlin

import com.pulumi.core.Output
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit

/**
 * Builder for [BranchRule].
 */
@PulumiTagMarker
public class BranchRuleResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: BranchRuleArgs = BranchRuleArgs()

    public var opts: CustomResourceOptions = CustomResourceOptions()

    /**
     * @param name The _unique_ name of the resulting resource.
     */
    public fun name(`value`: String) {
        this.name = value
    }

    /**
     * @param block The arguments to use to populate this resource's properties.
     */
    public suspend fun args(block: suspend BranchRuleArgsBuilder.() -> Unit) {
        val builder = BranchRuleArgsBuilder()
        block(builder)
        this.args = builder.build()
    }

    /**
     * @param block A bag of options that control this resource's behavior.
     */
    public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
        this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
    }

    internal fun build(): BranchRule {
        val builtJavaResource = com.pulumi.gcp.securesourcemanager.BranchRule(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return BranchRule(builtJavaResource)
    }
}

/**
 * BranchRule is the protection rule to enforce pre-defined rules on designated branches within a repository.
 * To get more information about BranchRule, see:
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/secure-source-manager/docs/overview)
 * ## Example Usage
 * ### Secure Source Manager Branch Rule Basic
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const instance = new gcp.securesourcemanager.Instance("instance", {
 *     location: "us-central1",
 *     instanceId: "my-basic-instance",
 * });
 * const repository = new gcp.securesourcemanager.Repository("repository", {
 *     repositoryId: "my-basic-repository",
 *     location: instance.location,
 *     instance: instance.name,
 * });
 * const basic = new gcp.securesourcemanager.BranchRule("basic", {
 *     branchRuleId: "my-basic-branchrule",
 *     repositoryId: repository.repositoryId,
 *     location: repository.location,
 *     includePattern: "main",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * instance = gcp.securesourcemanager.Instance("instance",
 *     location="us-central1",
 *     instance_id="my-basic-instance")
 * repository = gcp.securesourcemanager.Repository("repository",
 *     repository_id="my-basic-repository",
 *     location=instance.location,
 *     instance=instance.name)
 * basic = gcp.securesourcemanager.BranchRule("basic",
 *     branch_rule_id="my-basic-branchrule",
 *     repository_id=repository.repository_id,
 *     location=repository.location,
 *     include_pattern="main")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var instance = new Gcp.SecureSourceManager.Instance("instance", new()
 *     {
 *         Location = "us-central1",
 *         InstanceId = "my-basic-instance",
 *     });
 *     var repository = new Gcp.SecureSourceManager.Repository("repository", new()
 *     {
 *         RepositoryId = "my-basic-repository",
 *         Location = instance.Location,
 *         Instance = instance.Name,
 *     });
 *     var basic = new Gcp.SecureSourceManager.BranchRule("basic", new()
 *     {
 *         BranchRuleId = "my-basic-branchrule",
 *         RepositoryId = repository.RepositoryId,
 *         Location = repository.Location,
 *         IncludePattern = "main",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/securesourcemanager"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		instance, err := securesourcemanager.NewInstance(ctx, "instance", &securesourcemanager.InstanceArgs{
 * 			Location:   pulumi.String("us-central1"),
 * 			InstanceId: pulumi.String("my-basic-instance"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		repository, err := securesourcemanager.NewRepository(ctx, "repository", &securesourcemanager.RepositoryArgs{
 * 			RepositoryId: pulumi.String("my-basic-repository"),
 * 			Location:     instance.Location,
 * 			Instance:     instance.Name,
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = securesourcemanager.NewBranchRule(ctx, "basic", &securesourcemanager.BranchRuleArgs{
 * 			BranchRuleId:   pulumi.String("my-basic-branchrule"),
 * 			RepositoryId:   repository.RepositoryId,
 * 			Location:       repository.Location,
 * 			IncludePattern: pulumi.String("main"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.securesourcemanager.Instance;
 * import com.pulumi.gcp.securesourcemanager.InstanceArgs;
 * import com.pulumi.gcp.securesourcemanager.Repository;
 * import com.pulumi.gcp.securesourcemanager.RepositoryArgs;
 * import com.pulumi.gcp.securesourcemanager.BranchRule;
 * import com.pulumi.gcp.securesourcemanager.BranchRuleArgs;
 * 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 instance = new Instance("instance", InstanceArgs.builder()
 *             .location("us-central1")
 *             .instanceId("my-basic-instance")
 *             .build());
 *         var repository = new Repository("repository", RepositoryArgs.builder()
 *             .repositoryId("my-basic-repository")
 *             .location(instance.location())
 *             .instance(instance.name())
 *             .build());
 *         var basic = new BranchRule("basic", BranchRuleArgs.builder()
 *             .branchRuleId("my-basic-branchrule")
 *             .repositoryId(repository.repositoryId())
 *             .location(repository.location())
 *             .includePattern("main")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   instance:
 *     type: gcp:securesourcemanager:Instance
 *     properties:
 *       location: us-central1
 *       instanceId: my-basic-instance
 *   repository:
 *     type: gcp:securesourcemanager:Repository
 *     properties:
 *       repositoryId: my-basic-repository
 *       location: ${instance.location}
 *       instance: ${instance.name}
 *   basic:
 *     type: gcp:securesourcemanager:BranchRule
 *     properties:
 *       branchRuleId: my-basic-branchrule
 *       repositoryId: ${repository.repositoryId}
 *       location: ${repository.location}
 *       includePattern: main
 * ```
 * 
 * ### Secure Source Manager Branch Rule With Fields
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const instance = new gcp.securesourcemanager.Instance("instance", {
 *     location: "us-central1",
 *     instanceId: "my-initial-instance",
 * });
 * const repository = new gcp.securesourcemanager.Repository("repository", {
 *     repositoryId: "my-initial-repository",
 *     instance: instance.name,
 *     location: instance.location,
 * });
 * const _default = new gcp.securesourcemanager.BranchRule("default", {
 *     branchRuleId: "my-initial-branchrule",
 *     location: repository.location,
 *     repositoryId: repository.repositoryId,
 *     includePattern: "test",
 *     minimumApprovalsCount: 2,
 *     minimumReviewsCount: 2,
 *     requireCommentsResolved: true,
 *     requireLinearHistory: true,
 *     requirePullRequest: true,
 *     disabled: false,
 *     allowStaleReviews: false,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * instance = gcp.securesourcemanager.Instance("instance",
 *     location="us-central1",
 *     instance_id="my-initial-instance")
 * repository = gcp.securesourcemanager.Repository("repository",
 *     repository_id="my-initial-repository",
 *     instance=instance.name,
 *     location=instance.location)
 * default = gcp.securesourcemanager.BranchRule("default",
 *     branch_rule_id="my-initial-branchrule",
 *     location=repository.location,
 *     repository_id=repository.repository_id,
 *     include_pattern="test",
 *     minimum_approvals_count=2,
 *     minimum_reviews_count=2,
 *     require_comments_resolved=True,
 *     require_linear_history=True,
 *     require_pull_request=True,
 *     disabled=False,
 *     allow_stale_reviews=False)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var instance = new Gcp.SecureSourceManager.Instance("instance", new()
 *     {
 *         Location = "us-central1",
 *         InstanceId = "my-initial-instance",
 *     });
 *     var repository = new Gcp.SecureSourceManager.Repository("repository", new()
 *     {
 *         RepositoryId = "my-initial-repository",
 *         Instance = instance.Name,
 *         Location = instance.Location,
 *     });
 *     var @default = new Gcp.SecureSourceManager.BranchRule("default", new()
 *     {
 *         BranchRuleId = "my-initial-branchrule",
 *         Location = repository.Location,
 *         RepositoryId = repository.RepositoryId,
 *         IncludePattern = "test",
 *         MinimumApprovalsCount = 2,
 *         MinimumReviewsCount = 2,
 *         RequireCommentsResolved = true,
 *         RequireLinearHistory = true,
 *         RequirePullRequest = true,
 *         Disabled = false,
 *         AllowStaleReviews = false,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/securesourcemanager"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		instance, err := securesourcemanager.NewInstance(ctx, "instance", &securesourcemanager.InstanceArgs{
 * 			Location:   pulumi.String("us-central1"),
 * 			InstanceId: pulumi.String("my-initial-instance"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		repository, err := securesourcemanager.NewRepository(ctx, "repository", &securesourcemanager.RepositoryArgs{
 * 			RepositoryId: pulumi.String("my-initial-repository"),
 * 			Instance:     instance.Name,
 * 			Location:     instance.Location,
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = securesourcemanager.NewBranchRule(ctx, "default", &securesourcemanager.BranchRuleArgs{
 * 			BranchRuleId:            pulumi.String("my-initial-branchrule"),
 * 			Location:                repository.Location,
 * 			RepositoryId:            repository.RepositoryId,
 * 			IncludePattern:          pulumi.String("test"),
 * 			MinimumApprovalsCount:   pulumi.Int(2),
 * 			MinimumReviewsCount:     pulumi.Int(2),
 * 			RequireCommentsResolved: pulumi.Bool(true),
 * 			RequireLinearHistory:    pulumi.Bool(true),
 * 			RequirePullRequest:      pulumi.Bool(true),
 * 			Disabled:                pulumi.Bool(false),
 * 			AllowStaleReviews:       pulumi.Bool(false),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.securesourcemanager.Instance;
 * import com.pulumi.gcp.securesourcemanager.InstanceArgs;
 * import com.pulumi.gcp.securesourcemanager.Repository;
 * import com.pulumi.gcp.securesourcemanager.RepositoryArgs;
 * import com.pulumi.gcp.securesourcemanager.BranchRule;
 * import com.pulumi.gcp.securesourcemanager.BranchRuleArgs;
 * 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 instance = new Instance("instance", InstanceArgs.builder()
 *             .location("us-central1")
 *             .instanceId("my-initial-instance")
 *             .build());
 *         var repository = new Repository("repository", RepositoryArgs.builder()
 *             .repositoryId("my-initial-repository")
 *             .instance(instance.name())
 *             .location(instance.location())
 *             .build());
 *         var default_ = new BranchRule("default", BranchRuleArgs.builder()
 *             .branchRuleId("my-initial-branchrule")
 *             .location(repository.location())
 *             .repositoryId(repository.repositoryId())
 *             .includePattern("test")
 *             .minimumApprovalsCount(2)
 *             .minimumReviewsCount(2)
 *             .requireCommentsResolved(true)
 *             .requireLinearHistory(true)
 *             .requirePullRequest(true)
 *             .disabled(false)
 *             .allowStaleReviews(false)
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   instance:
 *     type: gcp:securesourcemanager:Instance
 *     properties:
 *       location: us-central1
 *       instanceId: my-initial-instance
 *   repository:
 *     type: gcp:securesourcemanager:Repository
 *     properties:
 *       repositoryId: my-initial-repository
 *       instance: ${instance.name}
 *       location: ${instance.location}
 *   default:
 *     type: gcp:securesourcemanager:BranchRule
 *     properties:
 *       branchRuleId: my-initial-branchrule
 *       location: ${repository.location}
 *       repositoryId: ${repository.repositoryId}
 *       includePattern: test
 *       minimumApprovalsCount: 2
 *       minimumReviewsCount: 2
 *       requireCommentsResolved: true
 *       requireLinearHistory: true
 *       requirePullRequest: true
 *       disabled: false
 *       allowStaleReviews: false
 * ```
 * 
 * ## Import
 * BranchRule can be imported using any of these accepted formats:
 * * `projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}/branchRules/{{branch_rule_id}}`
 * * `{{project}}/{{location}}/{{repository_id}}/{{branch_rule_id}}`
 * * `{{location}}/{{repository_id}}/{{branch_rule_id}}`
 * * `{{branch_rule_id}}`
 * When using the `pulumi import` command, BranchRule can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:securesourcemanager/branchRule:BranchRule default projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}/branchRules/{{branch_rule_id}}
 * ```
 * ```sh
 * $ pulumi import gcp:securesourcemanager/branchRule:BranchRule default {{project}}/{{location}}/{{repository_id}}/{{branch_rule_id}}
 * ```
 * ```sh
 * $ pulumi import gcp:securesourcemanager/branchRule:BranchRule default {{location}}/{{repository_id}}/{{branch_rule_id}}
 * ```
 * ```sh
 * $ pulumi import gcp:securesourcemanager/branchRule:BranchRule default {{branch_rule_id}}
 * ```
 */
public class BranchRule internal constructor(
    override val javaResource: com.pulumi.gcp.securesourcemanager.BranchRule,
) : KotlinCustomResource(javaResource, BranchRuleMapper) {
    /**
     * Determines if allow stale reviews or approvals before merging to the branch.
     */
    public val allowStaleReviews: Output?
        get() = javaResource.allowStaleReviews().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The ID for the BranchRule.
     */
    public val branchRuleId: Output
        get() = javaResource.branchRuleId().applyValue({ args0 -> args0 })

    /**
     * Time the BranchRule was created in UTC.
     */
    public val createTime: Output
        get() = javaResource.createTime().applyValue({ args0 -> args0 })

    /**
     * Determines if the branch rule is disabled or not.
     */
    public val disabled: Output?
        get() = javaResource.disabled().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The BranchRule matches branches based on the specified regular expression. Use .* to match all branches.
     */
    public val includePattern: Output
        get() = javaResource.includePattern().applyValue({ args0 -> args0 })

    /**
     * The location for the Repository.
     */
    public val location: Output
        get() = javaResource.location().applyValue({ args0 -> args0 })

    /**
     * The minimum number of approvals required for the branch rule to be matched.
     */
    public val minimumApprovalsCount: Output?
        get() = javaResource.minimumApprovalsCount().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The minimum number of reviews required for the branch rule to be matched.
     */
    public val minimumReviewsCount: Output?
        get() = javaResource.minimumReviewsCount().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The resource name for the BranchRule.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The ID of the project in which the resource belongs.
     * If it is not provided, the provider project is used.
     */
    public val project: Output
        get() = javaResource.project().applyValue({ args0 -> args0 })

    /**
     * The ID for the Repository.
     * - - -
     */
    public val repositoryId: Output
        get() = javaResource.repositoryId().applyValue({ args0 -> args0 })

    /**
     * Determines if require comments resolved before merging to the branch.
     */
    public val requireCommentsResolved: Output?
        get() = javaResource.requireCommentsResolved().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Determines if require linear history before merging to the branch.
     */
    public val requireLinearHistory: Output?
        get() = javaResource.requireLinearHistory().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Determines if the branch rule requires a pull request or not.
     */
    public val requirePullRequest: Output?
        get() = javaResource.requirePullRequest().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Unique identifier of the BranchRule.
     */
    public val uid: Output
        get() = javaResource.uid().applyValue({ args0 -> args0 })

    /**
     * Time the BranchRule was updated in UTC.
     */
    public val updateTime: Output
        get() = javaResource.updateTime().applyValue({ args0 -> args0 })
}

public object BranchRuleMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.securesourcemanager.BranchRule::class == javaResource::class

    override fun map(javaResource: Resource): BranchRule = BranchRule(
        javaResource as
            com.pulumi.gcp.securesourcemanager.BranchRule,
    )
}

/**
 * @see [BranchRule].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [BranchRule].
 */
public suspend fun branchRule(name: String, block: suspend BranchRuleResourceBuilder.() -> Unit): BranchRule {
    val builder = BranchRuleResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [BranchRule].
 * @param name The _unique_ name of the resulting resource.
 */
public fun branchRule(name: String): BranchRule {
    val builder = BranchRuleResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy