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

com.pulumi.azure.devtest.kotlin.Schedule.kt Maven / Gradle / Ivy

@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.azure.devtest.kotlin

import com.pulumi.azure.devtest.kotlin.outputs.ScheduleDailyRecurrence
import com.pulumi.azure.devtest.kotlin.outputs.ScheduleHourlyRecurrence
import com.pulumi.azure.devtest.kotlin.outputs.ScheduleNotificationSettings
import com.pulumi.azure.devtest.kotlin.outputs.ScheduleWeeklyRecurrence
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
import kotlin.collections.Map
import com.pulumi.azure.devtest.kotlin.outputs.ScheduleDailyRecurrence.Companion.toKotlin as scheduleDailyRecurrenceToKotlin
import com.pulumi.azure.devtest.kotlin.outputs.ScheduleHourlyRecurrence.Companion.toKotlin as scheduleHourlyRecurrenceToKotlin
import com.pulumi.azure.devtest.kotlin.outputs.ScheduleNotificationSettings.Companion.toKotlin as scheduleNotificationSettingsToKotlin
import com.pulumi.azure.devtest.kotlin.outputs.ScheduleWeeklyRecurrence.Companion.toKotlin as scheduleWeeklyRecurrenceToKotlin

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

    public var args: ScheduleArgs = ScheduleArgs()

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

/**
 * Manages automated startup and shutdown schedules for Azure Dev Test Lab.
 * ## 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 exampleLab = new azure.devtest.Lab("example", {
 *     name: "YourDevTestLab",
 *     location: example.location,
 *     resourceGroupName: example.name,
 * });
 * const exampleSchedule = new azure.devtest.Schedule("example", {
 *     name: "LabVmAutoStart",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     labName: exampleLab.name,
 *     status: "Enabled",
 *     weeklyRecurrence: {
 *         time: "1100",
 *         weekDays: [
 *             "Monday",
 *             "Tuesday",
 *         ],
 *     },
 *     timeZoneId: "Pacific Standard Time",
 *     taskType: "LabVmsStartupTask",
 *     notificationSettings: {},
 *     tags: {
 *         environment: "Production",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="example-resources",
 *     location="West Europe")
 * example_lab = azure.devtest.Lab("example",
 *     name="YourDevTestLab",
 *     location=example.location,
 *     resource_group_name=example.name)
 * example_schedule = azure.devtest.Schedule("example",
 *     name="LabVmAutoStart",
 *     location=example.location,
 *     resource_group_name=example.name,
 *     lab_name=example_lab.name,
 *     status="Enabled",
 *     weekly_recurrence={
 *         "time": "1100",
 *         "week_days": [
 *             "Monday",
 *             "Tuesday",
 *         ],
 *     },
 *     time_zone_id="Pacific Standard Time",
 *     task_type="LabVmsStartupTask",
 *     notification_settings={},
 *     tags={
 *         "environment": "Production",
 *     })
 * ```
 * ```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 exampleLab = new Azure.DevTest.Lab("example", new()
 *     {
 *         Name = "YourDevTestLab",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *     });
 *     var exampleSchedule = new Azure.DevTest.Schedule("example", new()
 *     {
 *         Name = "LabVmAutoStart",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *         LabName = exampleLab.Name,
 *         Status = "Enabled",
 *         WeeklyRecurrence = new Azure.DevTest.Inputs.ScheduleWeeklyRecurrenceArgs
 *         {
 *             Time = "1100",
 *             WeekDays = new[]
 *             {
 *                 "Monday",
 *                 "Tuesday",
 *             },
 *         },
 *         TimeZoneId = "Pacific Standard Time",
 *         TaskType = "LabVmsStartupTask",
 *         NotificationSettings = null,
 *         Tags =
 *         {
 *             { "environment", "Production" },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/devtest"
 * 	"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
 * 		}
 * 		exampleLab, err := devtest.NewLab(ctx, "example", &devtest.LabArgs{
 * 			Name:              pulumi.String("YourDevTestLab"),
 * 			Location:          example.Location,
 * 			ResourceGroupName: example.Name,
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = devtest.NewSchedule(ctx, "example", &devtest.ScheduleArgs{
 * 			Name:              pulumi.String("LabVmAutoStart"),
 * 			Location:          example.Location,
 * 			ResourceGroupName: example.Name,
 * 			LabName:           exampleLab.Name,
 * 			Status:            pulumi.String("Enabled"),
 * 			WeeklyRecurrence: &devtest.ScheduleWeeklyRecurrenceArgs{
 * 				Time: pulumi.String("1100"),
 * 				WeekDays: pulumi.StringArray{
 * 					pulumi.String("Monday"),
 * 					pulumi.String("Tuesday"),
 * 				},
 * 			},
 * 			TimeZoneId:           pulumi.String("Pacific Standard Time"),
 * 			TaskType:             pulumi.String("LabVmsStartupTask"),
 * 			NotificationSettings: nil,
 * 			Tags: pulumi.StringMap{
 * 				"environment": pulumi.String("Production"),
 * 			},
 * 		})
 * 		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.devtest.Lab;
 * import com.pulumi.azure.devtest.LabArgs;
 * import com.pulumi.azure.devtest.Schedule;
 * import com.pulumi.azure.devtest.ScheduleArgs;
 * import com.pulumi.azure.devtest.inputs.ScheduleWeeklyRecurrenceArgs;
 * import com.pulumi.azure.devtest.inputs.ScheduleNotificationSettingsArgs;
 * 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 exampleLab = new Lab("exampleLab", LabArgs.builder()
 *             .name("YourDevTestLab")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .build());
 *         var exampleSchedule = new Schedule("exampleSchedule", ScheduleArgs.builder()
 *             .name("LabVmAutoStart")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .labName(exampleLab.name())
 *             .status("Enabled")
 *             .weeklyRecurrence(ScheduleWeeklyRecurrenceArgs.builder()
 *                 .time("1100")
 *                 .weekDays(
 *                     "Monday",
 *                     "Tuesday")
 *                 .build())
 *             .timeZoneId("Pacific Standard Time")
 *             .taskType("LabVmsStartupTask")
 *             .notificationSettings()
 *             .tags(Map.of("environment", "Production"))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-resources
 *       location: West Europe
 *   exampleLab:
 *     type: azure:devtest:Lab
 *     name: example
 *     properties:
 *       name: YourDevTestLab
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *   exampleSchedule:
 *     type: azure:devtest:Schedule
 *     name: example
 *     properties:
 *       name: LabVmAutoStart
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *       labName: ${exampleLab.name}
 *       status: Enabled
 *       weeklyRecurrence:
 *         time: '1100'
 *         weekDays:
 *           - Monday
 *           - Tuesday
 *       timeZoneId: Pacific Standard Time
 *       taskType: LabVmsStartupTask
 *       notificationSettings: {}
 *       tags:
 *         environment: Production
 * ```
 * 
 * ## Import
 * DevTest Schedule's can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:devtest/schedule:Schedule example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.DevTestLab/labs/myDevTestLab/schedules/labvmautostart
 * ```
 */
public class Schedule internal constructor(
    override val javaResource: com.pulumi.azure.devtest.Schedule,
) : KotlinCustomResource(javaResource, ScheduleMapper) {
    /**
     * The properties of a daily schedule. If the schedule occurs once each day of the week, specify the daily recurrence. A `daily_recurrence` block as defined below.
     */
    public val dailyRecurrence: Output?
        get() = javaResource.dailyRecurrence().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> scheduleDailyRecurrenceToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * The properties of an hourly schedule. If the schedule occurs multiple times a day, specify the hourly recurrence. A `hourly_recurrence` block as defined below.
     */
    public val hourlyRecurrence: Output?
        get() = javaResource.hourlyRecurrence().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> scheduleHourlyRecurrenceToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * The name of the dev test lab. Changing this forces a new resource to be created.
     */
    public val labName: Output
        get() = javaResource.labName().applyValue({ args0 -> args0 })

    /**
     * The location where the schedule is created. Changing this forces a new resource to be created.
     */
    public val location: Output
        get() = javaResource.location().applyValue({ args0 -> args0 })

    /**
     * The name of the dev test lab schedule. Valid value for name depends on the `task_type`. For instance for task_type `LabVmsStartupTask` the name needs to be `LabVmAutoStart`. Changing this forces a new resource to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The notification setting of a schedule. A `notification_settings` block as defined below.
     */
    public val notificationSettings: Output
        get() = javaResource.notificationSettings().applyValue({ args0 ->
            args0.let({ args0 ->
                scheduleNotificationSettingsToKotlin(args0)
            })
        })

    /**
     * The name of the resource group in which to create the dev test lab schedule. Changing this forces a new resource to be created.
     */
    public val resourceGroupName: Output
        get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })

    /**
     * The status of this schedule. Possible values are `Enabled` and `Disabled`. Defaults to `Disabled`.
     */
    public val status: Output?
        get() = javaResource.status().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * A mapping of tags to assign to the resource.
     */
    public val tags: Output>?
        get() = javaResource.tags().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * The task type of the schedule. Possible values include `LabVmsShutdownTask` and `LabVmAutoStart`.
     */
    public val taskType: Output
        get() = javaResource.taskType().applyValue({ args0 -> args0 })

    /**
     * The time zone ID (e.g. Pacific Standard time).
     */
    public val timeZoneId: Output
        get() = javaResource.timeZoneId().applyValue({ args0 -> args0 })

    /**
     * The properties of a weekly schedule. If the schedule occurs only some days of the week, specify the weekly recurrence. A `weekly_recurrence` block as defined below.
     */
    public val weeklyRecurrence: Output?
        get() = javaResource.weeklyRecurrence().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> scheduleWeeklyRecurrenceToKotlin(args0) })
            }).orElse(null)
        })
}

public object ScheduleMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.devtest.Schedule::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy