com.pulumi.github.BranchDefault Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of github Show documentation
Show all versions of github Show documentation
A Pulumi package for creating and managing github cloud resources.
// *** 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.BranchDefaultArgs;
import com.pulumi.github.Utilities;
import com.pulumi.github.inputs.BranchDefaultState;
import java.lang.Boolean;
import java.lang.String;
import java.util.Optional;
import javax.annotation.Nullable;
/**
* Provides a GitHub branch default resource.
*
* This resource allows you to set the default branch for a given repository.
*
* Note that use of this resource is incompatible with the `default_branch` option of the `github.Repository` resource. Using both will result in plans always showing a diff.
*
* ## Example Usage
*
* Basic usage:
*
* <!--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.Branch;
* import com.pulumi.github.BranchArgs;
* import com.pulumi.github.BranchDefault;
* import com.pulumi.github.BranchDefaultArgs;
* 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 example = new Repository("example", RepositoryArgs.builder()
* .name("example")
* .description("My awesome codebase")
* .autoInit(true)
* .build());
*
* var development = new Branch("development", BranchArgs.builder()
* .repository(example.name())
* .branch("development")
* .build());
*
* var default_ = new BranchDefault("default", BranchDefaultArgs.builder()
* .repository(example.name())
* .branch(development.branch())
* .build());
*
* }
* }
* }
*
* <!--End PulumiCodeChooser -->
*
* Renaming to a branch that doesn't exist:
*
* <!--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.BranchDefault;
* import com.pulumi.github.BranchDefaultArgs;
* 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 example = new Repository("example", RepositoryArgs.builder()
* .name("example")
* .description("My awesome codebase")
* .autoInit(true)
* .build());
*
* var default_ = new BranchDefault("default", BranchDefaultArgs.builder()
* .repository(example.name())
* .branch("development")
* .rename(true)
* .build());
*
* }
* }
* }
*
* <!--End PulumiCodeChooser -->
*
* ## Import
*
* GitHub Branch Defaults can be imported using an ID made up of `repository`, e.g.
*
* ```sh
* $ pulumi import github:index/branchDefault:BranchDefault branch_default my-repo
* ```
*
*/
@ResourceType(type="github:index/branchDefault:BranchDefault")
public class BranchDefault extends com.pulumi.resources.CustomResource {
/**
* The branch (e.g. `main`)
*
*/
@Export(name="branch", refs={String.class}, tree="[0]")
private Output branch;
/**
* @return The branch (e.g. `main`)
*
*/
public Output branch() {
return this.branch;
}
@Export(name="etag", refs={String.class}, tree="[0]")
private Output etag;
public Output etag() {
return this.etag;
}
/**
* Indicate if it should rename the branch rather than use an existing branch. Defaults to `false`.
*
*/
@Export(name="rename", refs={Boolean.class}, tree="[0]")
private Output rename;
/**
* @return Indicate if it should rename the branch rather than use an existing branch. Defaults to `false`.
*
*/
public Output> rename() {
return Codegen.optional(this.rename);
}
/**
* The GitHub repository
*
*/
@Export(name="repository", refs={String.class}, tree="[0]")
private Output repository;
/**
* @return The GitHub repository
*
*/
public Output repository() {
return this.repository;
}
/**
*
* @param name The _unique_ name of the resulting resource.
*/
public BranchDefault(java.lang.String name) {
this(name, BranchDefaultArgs.Empty);
}
/**
*
* @param name The _unique_ name of the resulting resource.
* @param args The arguments to use to populate this resource's properties.
*/
public BranchDefault(java.lang.String name, BranchDefaultArgs 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 BranchDefault(java.lang.String name, BranchDefaultArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
super("github:index/branchDefault:BranchDefault", name, makeArgs(args, options), makeResourceOptions(options, Codegen.empty()), false);
}
private BranchDefault(java.lang.String name, Output id, @Nullable BranchDefaultState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
super("github:index/branchDefault:BranchDefault", name, state, makeResourceOptions(options, id), false);
}
private static BranchDefaultArgs makeArgs(BranchDefaultArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
if (options != null && options.getUrn().isPresent()) {
return null;
}
return args == null ? BranchDefaultArgs.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 BranchDefault get(java.lang.String name, Output id, @Nullable BranchDefaultState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
return new BranchDefault(name, id, state, options);
}
}