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

com.pulumi.github.BranchProtectionV3 Maven / Gradle / Ivy

The newest version!
// *** WARNING: this file was generated by pulumi-java-gen. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

package com.pulumi.github;

import com.pulumi.core.Output;
import com.pulumi.core.annotations.Export;
import com.pulumi.core.annotations.ResourceType;
import com.pulumi.core.internal.Codegen;
import com.pulumi.github.BranchProtectionV3Args;
import com.pulumi.github.Utilities;
import com.pulumi.github.inputs.BranchProtectionV3State;
import com.pulumi.github.outputs.BranchProtectionV3RequiredPullRequestReviews;
import com.pulumi.github.outputs.BranchProtectionV3RequiredStatusChecks;
import com.pulumi.github.outputs.BranchProtectionV3Restrictions;
import java.lang.Boolean;
import java.lang.String;
import java.util.Optional;
import javax.annotation.Nullable;

/**
 * Protects a GitHub branch.
 * 
 * The `github.BranchProtection` resource has moved to the GraphQL API, while this resource will continue to leverage the REST API.
 * 
 * This resource allows you to configure branch protection for repositories in your organization. When applied, the branch will be protected from forced pushes and deletion. Additional constraints, such as required status checks or restrictions on users, teams, and apps, can also be configured.
 * 
 * ## Example Usage
 * 
 * <!--Start PulumiCodeChooser -->
 * 
 * {@code
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.github.BranchProtectionV3;
 * import com.pulumi.github.BranchProtectionV3Args;
 * import com.pulumi.github.inputs.BranchProtectionV3RestrictionsArgs;
 * 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) {
 *         // Protect the main branch of the foo repository. Only allow a specific user to merge to the branch.
 *         var example = new BranchProtectionV3("example", BranchProtectionV3Args.builder()
 *             .repository(exampleGithubRepository.name())
 *             .branch("main")
 *             .restrictions(BranchProtectionV3RestrictionsArgs.builder()
 *                 .users("foo-user")
 *                 .build())
 *             .build());
 * 
 *     }
 * }
 * }
 * 
* <!--End PulumiCodeChooser --> * * <!--Start PulumiCodeChooser --> *
 * {@code
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.github.Repository;
 * import com.pulumi.github.RepositoryArgs;
 * import com.pulumi.github.Team;
 * import com.pulumi.github.TeamArgs;
 * import com.pulumi.github.BranchProtectionV3;
 * import com.pulumi.github.BranchProtectionV3Args;
 * import com.pulumi.github.inputs.BranchProtectionV3RequiredStatusChecksArgs;
 * import com.pulumi.github.inputs.BranchProtectionV3RequiredPullRequestReviewsArgs;
 * import com.pulumi.github.inputs.BranchProtectionV3RequiredPullRequestReviewsBypassPullRequestAllowancesArgs;
 * import com.pulumi.github.inputs.BranchProtectionV3RestrictionsArgs;
 * import com.pulumi.github.TeamRepository;
 * import com.pulumi.github.TeamRepositoryArgs;
 * 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 exampleRepository = new Repository("exampleRepository", RepositoryArgs.builder()
 *             .name("example")
 *             .build());
 * 
 *         var exampleTeam = new Team("exampleTeam", TeamArgs.builder()
 *             .name("Example Name")
 *             .build());
 * 
 *         // Protect the main branch of the foo repository. Additionally, require that
 *         // the "ci/check" check ran by the Github Actions app is passing and only allow
 *         // the engineers team merge to the branch.
 *         var example = new BranchProtectionV3("example", BranchProtectionV3Args.builder()
 *             .repository(exampleRepository.name())
 *             .branch("main")
 *             .enforceAdmins(true)
 *             .requiredStatusChecks(BranchProtectionV3RequiredStatusChecksArgs.builder()
 *                 .strict(false)
 *                 .checks("ci/check:824642007264")
 *                 .build())
 *             .requiredPullRequestReviews(BranchProtectionV3RequiredPullRequestReviewsArgs.builder()
 *                 .dismissStaleReviews(true)
 *                 .dismissalUsers("foo-user")
 *                 .dismissalTeams(exampleTeam.slug())
 *                 .dismissalApp("foo-app")
 *                 .bypassPullRequestAllowances(BranchProtectionV3RequiredPullRequestReviewsBypassPullRequestAllowancesArgs.builder()
 *                     .users("foo-user")
 *                     .teams(exampleTeam.slug())
 *                     .apps("foo-app")
 *                     .build())
 *                 .build())
 *             .restrictions(BranchProtectionV3RestrictionsArgs.builder()
 *                 .users("foo-user")
 *                 .teams(exampleTeam.slug())
 *                 .apps("foo-app")
 *                 .build())
 *             .build());
 * 
 *         var exampleTeamRepository = new TeamRepository("exampleTeamRepository", TeamRepositoryArgs.builder()
 *             .teamId(exampleTeam.id())
 *             .repository(exampleRepository.name())
 *             .permission("pull")
 *             .build());
 * 
 *     }
 * }
 * }
 * 
* <!--End PulumiCodeChooser --> * * ## Import * * GitHub Branch Protection can be imported using an ID made up of `repository:branch`, e.g. * * ```sh * $ pulumi import github:index/branchProtectionV3:BranchProtectionV3 terraform terraform:main * ``` * */ @ResourceType(type="github:index/branchProtectionV3:BranchProtectionV3") public class BranchProtectionV3 extends com.pulumi.resources.CustomResource { /** * The Git branch to protect. * */ @Export(name="branch", refs={String.class}, tree="[0]") private Output branch; /** * @return The Git branch to protect. * */ public Output branch() { return this.branch; } /** * Boolean, setting this to `true` enforces status checks for repository administrators. * */ @Export(name="enforceAdmins", refs={Boolean.class}, tree="[0]") private Output enforceAdmins; /** * @return Boolean, setting this to `true` enforces status checks for repository administrators. * */ public Output> enforceAdmins() { return Codegen.optional(this.enforceAdmins); } @Export(name="etag", refs={String.class}, tree="[0]") private Output etag; public Output etag() { return this.etag; } /** * The GitHub repository name. * */ @Export(name="repository", refs={String.class}, tree="[0]") private Output repository; /** * @return The GitHub repository name. * */ public Output repository() { return this.repository; } /** * Boolean, setting this to `true` requires all conversations on code must be resolved before a pull request can be merged. * */ @Export(name="requireConversationResolution", refs={Boolean.class}, tree="[0]") private Output requireConversationResolution; /** * @return Boolean, setting this to `true` requires all conversations on code must be resolved before a pull request can be merged. * */ public Output> requireConversationResolution() { return Codegen.optional(this.requireConversationResolution); } /** * Boolean, setting this to `true` requires all commits to be signed with GPG. * */ @Export(name="requireSignedCommits", refs={Boolean.class}, tree="[0]") private Output requireSignedCommits; /** * @return Boolean, setting this to `true` requires all commits to be signed with GPG. * */ public Output> requireSignedCommits() { return Codegen.optional(this.requireSignedCommits); } /** * Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details. * */ @Export(name="requiredPullRequestReviews", refs={BranchProtectionV3RequiredPullRequestReviews.class}, tree="[0]") private Output requiredPullRequestReviews; /** * @return Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details. * */ public Output> requiredPullRequestReviews() { return Codegen.optional(this.requiredPullRequestReviews); } /** * Enforce restrictions for required status checks. See Required Status Checks below for details. * */ @Export(name="requiredStatusChecks", refs={BranchProtectionV3RequiredStatusChecks.class}, tree="[0]") private Output requiredStatusChecks; /** * @return Enforce restrictions for required status checks. See Required Status Checks below for details. * */ public Output> requiredStatusChecks() { return Codegen.optional(this.requiredStatusChecks); } /** * Enforce restrictions for the users and teams that may push to the branch. See Restrictions below for details. * */ @Export(name="restrictions", refs={BranchProtectionV3Restrictions.class}, tree="[0]") private Output restrictions; /** * @return Enforce restrictions for the users and teams that may push to the branch. See Restrictions below for details. * */ public Output> restrictions() { return Codegen.optional(this.restrictions); } /** * * @param name The _unique_ name of the resulting resource. */ public BranchProtectionV3(java.lang.String name) { this(name, BranchProtectionV3Args.Empty); } /** * * @param name The _unique_ name of the resulting resource. * @param args The arguments to use to populate this resource's properties. */ public BranchProtectionV3(java.lang.String name, BranchProtectionV3Args args) { this(name, args, null); } /** * * @param name The _unique_ name of the resulting resource. * @param args The arguments to use to populate this resource's properties. * @param options A bag of options that control this resource's behavior. */ public BranchProtectionV3(java.lang.String name, BranchProtectionV3Args args, @Nullable com.pulumi.resources.CustomResourceOptions options) { super("github:index/branchProtectionV3:BranchProtectionV3", name, makeArgs(args, options), makeResourceOptions(options, Codegen.empty()), false); } private BranchProtectionV3(java.lang.String name, Output id, @Nullable BranchProtectionV3State state, @Nullable com.pulumi.resources.CustomResourceOptions options) { super("github:index/branchProtectionV3:BranchProtectionV3", name, state, makeResourceOptions(options, id), false); } private static BranchProtectionV3Args makeArgs(BranchProtectionV3Args args, @Nullable com.pulumi.resources.CustomResourceOptions options) { if (options != null && options.getUrn().isPresent()) { return null; } return args == null ? BranchProtectionV3Args.Empty : args; } private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output id) { var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder() .version(Utilities.getVersion()) .build(); return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id); } /** * Get an existing Host resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state * @param options Optional settings to control the behavior of the CustomResource. */ public static BranchProtectionV3 get(java.lang.String name, Output id, @Nullable BranchProtectionV3State state, @Nullable com.pulumi.resources.CustomResourceOptions options) { return new BranchProtectionV3(name, id, state, options); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy