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

com.pulumi.azure.automation.kotlin.Watcher.kt Maven / Gradle / Ivy

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

package com.pulumi.azure.automation.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
import kotlin.collections.Map

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

    public var args: WatcherArgs = WatcherArgs()

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

/**
 * Manages an Automation Wacher.
 * ## 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 exampleAccount = new azure.automation.Account("example", {
 *     name: "example-account",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     skuName: "Basic",
 * });
 * const exampleHybridRunbookWorkerGroup = new azure.automation.HybridRunbookWorkerGroup("example", {
 *     name: "example",
 *     resourceGroupName: example.name,
 *     automationAccountName: exampleAccount.name,
 * });
 * const exampleRunBook = new azure.automation.RunBook("example", {
 *     name: "Get-AzureVMTutorial",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     automationAccountName: exampleAccount.name,
 *     logVerbose: true,
 *     logProgress: true,
 *     description: "This is an example runbook",
 *     runbookType: "PowerShellWorkflow",
 *     publishContentLink: {
 *         uri: "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/c4935ffb69246a6058eb24f54640f53f69d3ac9f/101-automation-runbook-getvms/Runbooks/Get-AzureVMTutorial.ps1",
 *     },
 * });
 * const exampleWatcher = new azure.automation.Watcher("example", {
 *     name: "example",
 *     automationAccountId: exampleAccount.id,
 *     location: "West Europe",
 *     scriptName: exampleRunBook.name,
 *     scriptRunOn: exampleHybridRunbookWorkerGroup.name,
 *     description: "example-watcher desc",
 *     executionFrequencyInSeconds: 42,
 *     tags: {
 *         foo: "bar",
 *     },
 *     scriptParameters: {
 *         foo: "bar",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="example-resources",
 *     location="West Europe")
 * example_account = azure.automation.Account("example",
 *     name="example-account",
 *     location=example.location,
 *     resource_group_name=example.name,
 *     sku_name="Basic")
 * example_hybrid_runbook_worker_group = azure.automation.HybridRunbookWorkerGroup("example",
 *     name="example",
 *     resource_group_name=example.name,
 *     automation_account_name=example_account.name)
 * example_run_book = azure.automation.RunBook("example",
 *     name="Get-AzureVMTutorial",
 *     location=example.location,
 *     resource_group_name=example.name,
 *     automation_account_name=example_account.name,
 *     log_verbose=True,
 *     log_progress=True,
 *     description="This is an example runbook",
 *     runbook_type="PowerShellWorkflow",
 *     publish_content_link={
 *         "uri": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/c4935ffb69246a6058eb24f54640f53f69d3ac9f/101-automation-runbook-getvms/Runbooks/Get-AzureVMTutorial.ps1",
 *     })
 * example_watcher = azure.automation.Watcher("example",
 *     name="example",
 *     automation_account_id=example_account.id,
 *     location="West Europe",
 *     script_name=example_run_book.name,
 *     script_run_on=example_hybrid_runbook_worker_group.name,
 *     description="example-watcher desc",
 *     execution_frequency_in_seconds=42,
 *     tags={
 *         "foo": "bar",
 *     },
 *     script_parameters={
 *         "foo": "bar",
 *     })
 * ```
 * ```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 exampleAccount = new Azure.Automation.Account("example", new()
 *     {
 *         Name = "example-account",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *         SkuName = "Basic",
 *     });
 *     var exampleHybridRunbookWorkerGroup = new Azure.Automation.HybridRunbookWorkerGroup("example", new()
 *     {
 *         Name = "example",
 *         ResourceGroupName = example.Name,
 *         AutomationAccountName = exampleAccount.Name,
 *     });
 *     var exampleRunBook = new Azure.Automation.RunBook("example", new()
 *     {
 *         Name = "Get-AzureVMTutorial",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *         AutomationAccountName = exampleAccount.Name,
 *         LogVerbose = true,
 *         LogProgress = true,
 *         Description = "This is an example runbook",
 *         RunbookType = "PowerShellWorkflow",
 *         PublishContentLink = new Azure.Automation.Inputs.RunBookPublishContentLinkArgs
 *         {
 *             Uri = "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/c4935ffb69246a6058eb24f54640f53f69d3ac9f/101-automation-runbook-getvms/Runbooks/Get-AzureVMTutorial.ps1",
 *         },
 *     });
 *     var exampleWatcher = new Azure.Automation.Watcher("example", new()
 *     {
 *         Name = "example",
 *         AutomationAccountId = exampleAccount.Id,
 *         Location = "West Europe",
 *         ScriptName = exampleRunBook.Name,
 *         ScriptRunOn = exampleHybridRunbookWorkerGroup.Name,
 *         Description = "example-watcher desc",
 *         ExecutionFrequencyInSeconds = 42,
 *         Tags =
 *         {
 *             { "foo", "bar" },
 *         },
 *         ScriptParameters =
 *         {
 *             { "foo", "bar" },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/automation"
 * 	"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
 * 		}
 * 		exampleAccount, err := automation.NewAccount(ctx, "example", &automation.AccountArgs{
 * 			Name:              pulumi.String("example-account"),
 * 			Location:          example.Location,
 * 			ResourceGroupName: example.Name,
 * 			SkuName:           pulumi.String("Basic"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleHybridRunbookWorkerGroup, err := automation.NewHybridRunbookWorkerGroup(ctx, "example", &automation.HybridRunbookWorkerGroupArgs{
 * 			Name:                  pulumi.String("example"),
 * 			ResourceGroupName:     example.Name,
 * 			AutomationAccountName: exampleAccount.Name,
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleRunBook, err := automation.NewRunBook(ctx, "example", &automation.RunBookArgs{
 * 			Name:                  pulumi.String("Get-AzureVMTutorial"),
 * 			Location:              example.Location,
 * 			ResourceGroupName:     example.Name,
 * 			AutomationAccountName: exampleAccount.Name,
 * 			LogVerbose:            pulumi.Bool(true),
 * 			LogProgress:           pulumi.Bool(true),
 * 			Description:           pulumi.String("This is an example runbook"),
 * 			RunbookType:           pulumi.String("PowerShellWorkflow"),
 * 			PublishContentLink: &automation.RunBookPublishContentLinkArgs{
 * 				Uri: pulumi.String("https://raw.githubusercontent.com/Azure/azure-quickstart-templates/c4935ffb69246a6058eb24f54640f53f69d3ac9f/101-automation-runbook-getvms/Runbooks/Get-AzureVMTutorial.ps1"),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = automation.NewWatcher(ctx, "example", &automation.WatcherArgs{
 * 			Name:                        pulumi.String("example"),
 * 			AutomationAccountId:         exampleAccount.ID(),
 * 			Location:                    pulumi.String("West Europe"),
 * 			ScriptName:                  exampleRunBook.Name,
 * 			ScriptRunOn:                 exampleHybridRunbookWorkerGroup.Name,
 * 			Description:                 pulumi.String("example-watcher desc"),
 * 			ExecutionFrequencyInSeconds: pulumi.Int(42),
 * 			Tags: pulumi.StringMap{
 * 				"foo": pulumi.String("bar"),
 * 			},
 * 			ScriptParameters: pulumi.StringMap{
 * 				"foo": pulumi.String("bar"),
 * 			},
 * 		})
 * 		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.automation.Account;
 * import com.pulumi.azure.automation.AccountArgs;
 * import com.pulumi.azure.automation.HybridRunbookWorkerGroup;
 * import com.pulumi.azure.automation.HybridRunbookWorkerGroupArgs;
 * import com.pulumi.azure.automation.RunBook;
 * import com.pulumi.azure.automation.RunBookArgs;
 * import com.pulumi.azure.automation.inputs.RunBookPublishContentLinkArgs;
 * import com.pulumi.azure.automation.Watcher;
 * import com.pulumi.azure.automation.WatcherArgs;
 * 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 exampleAccount = new Account("exampleAccount", AccountArgs.builder()
 *             .name("example-account")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .skuName("Basic")
 *             .build());
 *         var exampleHybridRunbookWorkerGroup = new HybridRunbookWorkerGroup("exampleHybridRunbookWorkerGroup", HybridRunbookWorkerGroupArgs.builder()
 *             .name("example")
 *             .resourceGroupName(example.name())
 *             .automationAccountName(exampleAccount.name())
 *             .build());
 *         var exampleRunBook = new RunBook("exampleRunBook", RunBookArgs.builder()
 *             .name("Get-AzureVMTutorial")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .automationAccountName(exampleAccount.name())
 *             .logVerbose("true")
 *             .logProgress("true")
 *             .description("This is an example runbook")
 *             .runbookType("PowerShellWorkflow")
 *             .publishContentLink(RunBookPublishContentLinkArgs.builder()
 *                 .uri("https://raw.githubusercontent.com/Azure/azure-quickstart-templates/c4935ffb69246a6058eb24f54640f53f69d3ac9f/101-automation-runbook-getvms/Runbooks/Get-AzureVMTutorial.ps1")
 *                 .build())
 *             .build());
 *         var exampleWatcher = new Watcher("exampleWatcher", WatcherArgs.builder()
 *             .name("example")
 *             .automationAccountId(exampleAccount.id())
 *             .location("West Europe")
 *             .scriptName(exampleRunBook.name())
 *             .scriptRunOn(exampleHybridRunbookWorkerGroup.name())
 *             .description("example-watcher desc")
 *             .executionFrequencyInSeconds(42)
 *             .tags(Map.of("foo", "bar"))
 *             .scriptParameters(Map.of("foo", "bar"))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-resources
 *       location: West Europe
 *   exampleAccount:
 *     type: azure:automation:Account
 *     name: example
 *     properties:
 *       name: example-account
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *       skuName: Basic
 *   exampleHybridRunbookWorkerGroup:
 *     type: azure:automation:HybridRunbookWorkerGroup
 *     name: example
 *     properties:
 *       name: example
 *       resourceGroupName: ${example.name}
 *       automationAccountName: ${exampleAccount.name}
 *   exampleRunBook:
 *     type: azure:automation:RunBook
 *     name: example
 *     properties:
 *       name: Get-AzureVMTutorial
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *       automationAccountName: ${exampleAccount.name}
 *       logVerbose: 'true'
 *       logProgress: 'true'
 *       description: This is an example runbook
 *       runbookType: PowerShellWorkflow
 *       publishContentLink:
 *         uri: https://raw.githubusercontent.com/Azure/azure-quickstart-templates/c4935ffb69246a6058eb24f54640f53f69d3ac9f/101-automation-runbook-getvms/Runbooks/Get-AzureVMTutorial.ps1
 *   exampleWatcher:
 *     type: azure:automation:Watcher
 *     name: example
 *     properties:
 *       name: example
 *       automationAccountId: ${exampleAccount.id}
 *       location: West Europe
 *       scriptName: ${exampleRunBook.name}
 *       scriptRunOn: ${exampleHybridRunbookWorkerGroup.name}
 *       description: example-watcher desc
 *       executionFrequencyInSeconds: 42
 *       tags:
 *         foo: bar
 *       scriptParameters:
 *         foo: bar
 * ```
 * 
 * ## Import
 * Automation Watchers can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:automation/watcher:Watcher example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Automation/automationAccounts/account1/watchers/watch1
 * ```
 */
public class Watcher internal constructor(
    override val javaResource: com.pulumi.azure.automation.Watcher,
) : KotlinCustomResource(javaResource, WatcherMapper) {
    /**
     * The ID of Automation Account to manage this Watcher. Changing this forces a new Watcher to be created.
     */
    public val automationAccountId: Output
        get() = javaResource.automationAccountId().applyValue({ args0 -> args0 })

    /**
     * A description of this Automation Watcher.
     */
    public val description: Output?
        get() = javaResource.description().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * A string of etag assigned to this Automation Watcher.
     */
    public val etag: Output?
        get() = javaResource.etag().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * Specify the frequency at which the watcher is invoked.
     */
    public val executionFrequencyInSeconds: Output
        get() = javaResource.executionFrequencyInSeconds().applyValue({ args0 -> args0 })

    /**
     * The Azure Region where the Automation Watcher should exist. Changing this forces a new Automation Watcher to be created.
     */
    public val location: Output
        get() = javaResource.location().applyValue({ args0 -> args0 })

    /**
     * The name which should be used for this Automation Watcher. Changing this forces a new Automation Watcher to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * Specify the name of an existing runbook this watcher is attached to. Changing this forces a new Automation to be created.
     */
    public val scriptName: Output
        get() = javaResource.scriptName().applyValue({ args0 -> args0 })

    /**
     * Specifies a list of key-vaule parameters. Changing this forces a new Automation watcher to be created.
     */
    public val scriptParameters: Output>?
        get() = javaResource.scriptParameters().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 -> args0.key.to(args0.value) }).toMap()
            }).orElse(null)
        })

    /**
     * Specify the name of the Hybrid work group the watcher will run on.
     */
    public val scriptRunOn: Output
        get() = javaResource.scriptRunOn().applyValue({ args0 -> args0 })

    /**
     * The current status of the Automation Watcher.
     */
    public val status: Output
        get() = javaResource.status().applyValue({ args0 -> args0 })

    /**
     * A mapping of tags which should be assigned to the Automation Watcher.
     */
    public val tags: Output>?
        get() = javaResource.tags().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })
}

public object WatcherMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.automation.Watcher::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy