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

com.pulumi.azure.appservice.kotlin.SourceControl.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: 6.15.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.azure.appservice.kotlin

import com.pulumi.azure.appservice.kotlin.outputs.SourceControlGithubActionConfiguration
import com.pulumi.azure.appservice.kotlin.outputs.SourceControlGithubActionConfiguration.Companion.toKotlin
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.String
import kotlin.Suppress
import kotlin.Unit

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

    public var args: SourceControlArgs = SourceControlArgs()

    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 SourceControlArgsBuilder.() -> Unit) {
        val builder = SourceControlArgsBuilder()
        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(): SourceControl {
        val builtJavaResource = com.pulumi.azure.appservice.SourceControl(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return SourceControl(builtJavaResource)
    }
}

/**
 * Manages an App Service Web App or Function App Source Control Configuration.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "example-resources",
 *     location: "West Europe",
 * });
 * const exampleServicePlan = new azure.appservice.ServicePlan("example", {
 *     name: "example",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     osType: "Linux",
 *     skuName: "P1v2",
 * });
 * const exampleLinuxWebApp = new azure.appservice.LinuxWebApp("example", {
 *     name: "example",
 *     resourceGroupName: example.name,
 *     location: exampleServicePlan.location,
 *     servicePlanId: exampleServicePlan.id,
 *     siteConfig: {},
 * });
 * const exampleSourceControl = new azure.appservice.SourceControl("example", {
 *     appId: exampleLinuxWebApp.id,
 *     repoUrl: "https://github.com/Azure-Samples/python-docs-hello-world",
 *     branch: "master",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="example-resources",
 *     location="West Europe")
 * example_service_plan = azure.appservice.ServicePlan("example",
 *     name="example",
 *     resource_group_name=example.name,
 *     location=example.location,
 *     os_type="Linux",
 *     sku_name="P1v2")
 * example_linux_web_app = azure.appservice.LinuxWebApp("example",
 *     name="example",
 *     resource_group_name=example.name,
 *     location=example_service_plan.location,
 *     service_plan_id=example_service_plan.id,
 *     site_config={})
 * example_source_control = azure.appservice.SourceControl("example",
 *     app_id=example_linux_web_app.id,
 *     repo_url="https://github.com/Azure-Samples/python-docs-hello-world",
 *     branch="master")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Azure.Core.ResourceGroup("example", new()
 *     {
 *         Name = "example-resources",
 *         Location = "West Europe",
 *     });
 *     var exampleServicePlan = new Azure.AppService.ServicePlan("example", new()
 *     {
 *         Name = "example",
 *         ResourceGroupName = example.Name,
 *         Location = example.Location,
 *         OsType = "Linux",
 *         SkuName = "P1v2",
 *     });
 *     var exampleLinuxWebApp = new Azure.AppService.LinuxWebApp("example", new()
 *     {
 *         Name = "example",
 *         ResourceGroupName = example.Name,
 *         Location = exampleServicePlan.Location,
 *         ServicePlanId = exampleServicePlan.Id,
 *         SiteConfig = null,
 *     });
 *     var exampleSourceControl = new Azure.AppService.SourceControl("example", new()
 *     {
 *         AppId = exampleLinuxWebApp.Id,
 *         RepoUrl = "https://github.com/Azure-Samples/python-docs-hello-world",
 *         Branch = "master",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/appservice"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
 * 			Name:     pulumi.String("example-resources"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleServicePlan, err := appservice.NewServicePlan(ctx, "example", &appservice.ServicePlanArgs{
 * 			Name:              pulumi.String("example"),
 * 			ResourceGroupName: example.Name,
 * 			Location:          example.Location,
 * 			OsType:            pulumi.String("Linux"),
 * 			SkuName:           pulumi.String("P1v2"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleLinuxWebApp, err := appservice.NewLinuxWebApp(ctx, "example", &appservice.LinuxWebAppArgs{
 * 			Name:              pulumi.String("example"),
 * 			ResourceGroupName: example.Name,
 * 			Location:          exampleServicePlan.Location,
 * 			ServicePlanId:     exampleServicePlan.ID(),
 * 			SiteConfig:        nil,
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = appservice.NewSourceControl(ctx, "example", &appservice.SourceControlArgs{
 * 			AppId:   exampleLinuxWebApp.ID(),
 * 			RepoUrl: pulumi.String("https://github.com/Azure-Samples/python-docs-hello-world"),
 * 			Branch:  pulumi.String("master"),
 * 		})
 * 		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.azure.core.ResourceGroup;
 * import com.pulumi.azure.core.ResourceGroupArgs;
 * import com.pulumi.azure.appservice.ServicePlan;
 * import com.pulumi.azure.appservice.ServicePlanArgs;
 * import com.pulumi.azure.appservice.LinuxWebApp;
 * import com.pulumi.azure.appservice.LinuxWebAppArgs;
 * import com.pulumi.azure.appservice.inputs.LinuxWebAppSiteConfigArgs;
 * import com.pulumi.azure.appservice.SourceControl;
 * import com.pulumi.azure.appservice.SourceControlArgs;
 * 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 ResourceGroup("example", ResourceGroupArgs.builder()
 *             .name("example-resources")
 *             .location("West Europe")
 *             .build());
 *         var exampleServicePlan = new ServicePlan("exampleServicePlan", ServicePlanArgs.builder()
 *             .name("example")
 *             .resourceGroupName(example.name())
 *             .location(example.location())
 *             .osType("Linux")
 *             .skuName("P1v2")
 *             .build());
 *         var exampleLinuxWebApp = new LinuxWebApp("exampleLinuxWebApp", LinuxWebAppArgs.builder()
 *             .name("example")
 *             .resourceGroupName(example.name())
 *             .location(exampleServicePlan.location())
 *             .servicePlanId(exampleServicePlan.id())
 *             .siteConfig()
 *             .build());
 *         var exampleSourceControl = new SourceControl("exampleSourceControl", SourceControlArgs.builder()
 *             .appId(exampleLinuxWebApp.id())
 *             .repoUrl("https://github.com/Azure-Samples/python-docs-hello-world")
 *             .branch("master")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-resources
 *       location: West Europe
 *   exampleServicePlan:
 *     type: azure:appservice:ServicePlan
 *     name: example
 *     properties:
 *       name: example
 *       resourceGroupName: ${example.name}
 *       location: ${example.location}
 *       osType: Linux
 *       skuName: P1v2
 *   exampleLinuxWebApp:
 *     type: azure:appservice:LinuxWebApp
 *     name: example
 *     properties:
 *       name: example
 *       resourceGroupName: ${example.name}
 *       location: ${exampleServicePlan.location}
 *       servicePlanId: ${exampleServicePlan.id}
 *       siteConfig: {}
 *   exampleSourceControl:
 *     type: azure:appservice:SourceControl
 *     name: example
 *     properties:
 *       appId: ${exampleLinuxWebApp.id}
 *       repoUrl: https://github.com/Azure-Samples/python-docs-hello-world
 *       branch: master
 * ```
 * 
 * ## Import
 * App Service Source Controls can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:appservice/sourceControl:SourceControl example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1
 * ```
 */
public class SourceControl internal constructor(
    override val javaResource: com.pulumi.azure.appservice.SourceControl,
) : KotlinCustomResource(javaResource, SourceControlMapper) {
    /**
     * The ID of the Windows or Linux Web App. Changing this forces a new resource to be created.
     * > **NOTE:** Function apps are not supported at this time.
     */
    public val appId: Output
        get() = javaResource.appId().applyValue({ args0 -> args0 })

    /**
     * The branch name to use for deployments. Changing this forces a new resource to be created.
     */
    public val branch: Output
        get() = javaResource.branch().applyValue({ args0 -> args0 })

    /**
     * A `github_action_configuration` block as defined below. Changing this forces a new resource to be created.
     */
    public val githubActionConfiguration: Output?
        get() = javaResource.githubActionConfiguration().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> toKotlin(args0) })
            }).orElse(null)
        })

    /**
     * The URL for the repository. Changing this forces a new resource to be created.
     */
    public val repoUrl: Output
        get() = javaResource.repoUrl().applyValue({ args0 -> args0 })

    /**
     * Should the Deployment Rollback be enabled? Defaults to `false`. Changing this forces a new resource to be created.
     * > **NOTE:** Azure can typically set this value automatically based on the `repo_url` value.
     */
    public val rollbackEnabled: Output?
        get() = javaResource.rollbackEnabled().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The SCM Type in use. This value is decoded by the service from the repository information supplied.
     */
    public val scmType: Output
        get() = javaResource.scmType().applyValue({ args0 -> args0 })

    /**
     * Should the App use local Git configuration. Changing this forces a new resource to be created.
     */
    public val useLocalGit: Output?
        get() = javaResource.useLocalGit().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Should code be deployed manually. Set to `false` to enable continuous integration, such as webhooks into online repos such as GitHub. Defaults to `false`. Changing this forces a new resource to be created.
     */
    public val useManualIntegration: Output?
        get() = javaResource.useManualIntegration().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The repository specified is Mercurial. Defaults to `false`. Changing this forces a new resource to be created.
     */
    public val useMercurial: Output?
        get() = javaResource.useMercurial().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Indicates if the Slot uses a GitHub action for deployment. This value is decoded by the service from the repository information supplied.
     */
    public val usesGithubAction: Output
        get() = javaResource.usesGithubAction().applyValue({ args0 -> args0 })
}

public object SourceControlMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.appservice.SourceControl::class == javaResource::class

    override fun map(javaResource: Resource): SourceControl = SourceControl(
        javaResource as
            com.pulumi.azure.appservice.SourceControl,
    )
}

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy