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

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

package com.pulumi.azure.sentinel.kotlin

import com.pulumi.azure.sentinel.kotlin.outputs.AutomationRuleActionIncident
import com.pulumi.azure.sentinel.kotlin.outputs.AutomationRuleActionPlaybook
import com.pulumi.azure.sentinel.kotlin.outputs.AutomationRuleCondition
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.Deprecated
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import com.pulumi.azure.sentinel.kotlin.outputs.AutomationRuleActionIncident.Companion.toKotlin as automationRuleActionIncidentToKotlin
import com.pulumi.azure.sentinel.kotlin.outputs.AutomationRuleActionPlaybook.Companion.toKotlin as automationRuleActionPlaybookToKotlin
import com.pulumi.azure.sentinel.kotlin.outputs.AutomationRuleCondition.Companion.toKotlin as automationRuleConditionToKotlin

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

    public var args: AutomationRuleArgs = AutomationRuleArgs()

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

/**
 * Manages a Sentinel Automation Rule.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "example-rg",
 *     location: "west europe",
 * });
 * const exampleAnalyticsWorkspace = new azure.operationalinsights.AnalyticsWorkspace("example", {
 *     name: "example-workspace",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     sku: "PerGB2018",
 * });
 * const exampleLogAnalyticsWorkspaceOnboarding = new azure.sentinel.LogAnalyticsWorkspaceOnboarding("example", {workspaceId: exampleAnalyticsWorkspace.id});
 * const exampleAutomationRule = new azure.sentinel.AutomationRule("example", {
 *     name: "56094f72-ac3f-40e7-a0c0-47bd95f70336",
 *     logAnalyticsWorkspaceId: exampleLogAnalyticsWorkspaceOnboarding.workspaceId,
 *     displayName: "automation_rule1",
 *     order: 1,
 *     actionIncidents: [{
 *         order: 1,
 *         status: "Active",
 *     }],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="example-rg",
 *     location="west europe")
 * example_analytics_workspace = azure.operationalinsights.AnalyticsWorkspace("example",
 *     name="example-workspace",
 *     location=example.location,
 *     resource_group_name=example.name,
 *     sku="PerGB2018")
 * example_log_analytics_workspace_onboarding = azure.sentinel.LogAnalyticsWorkspaceOnboarding("example", workspace_id=example_analytics_workspace.id)
 * example_automation_rule = azure.sentinel.AutomationRule("example",
 *     name="56094f72-ac3f-40e7-a0c0-47bd95f70336",
 *     log_analytics_workspace_id=example_log_analytics_workspace_onboarding.workspace_id,
 *     display_name="automation_rule1",
 *     order=1,
 *     action_incidents=[azure.sentinel.AutomationRuleActionIncidentArgs(
 *         order=1,
 *         status="Active",
 *     )])
 * ```
 * ```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-rg",
 *         Location = "west europe",
 *     });
 *     var exampleAnalyticsWorkspace = new Azure.OperationalInsights.AnalyticsWorkspace("example", new()
 *     {
 *         Name = "example-workspace",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *         Sku = "PerGB2018",
 *     });
 *     var exampleLogAnalyticsWorkspaceOnboarding = new Azure.Sentinel.LogAnalyticsWorkspaceOnboarding("example", new()
 *     {
 *         WorkspaceId = exampleAnalyticsWorkspace.Id,
 *     });
 *     var exampleAutomationRule = new Azure.Sentinel.AutomationRule("example", new()
 *     {
 *         Name = "56094f72-ac3f-40e7-a0c0-47bd95f70336",
 *         LogAnalyticsWorkspaceId = exampleLogAnalyticsWorkspaceOnboarding.WorkspaceId,
 *         DisplayName = "automation_rule1",
 *         Order = 1,
 *         ActionIncidents = new[]
 *         {
 *             new Azure.Sentinel.Inputs.AutomationRuleActionIncidentArgs
 *             {
 *                 Order = 1,
 *                 Status = "Active",
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/operationalinsights"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/sentinel"
 * 	"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-rg"),
 * 			Location: pulumi.String("west europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleAnalyticsWorkspace, err := operationalinsights.NewAnalyticsWorkspace(ctx, "example", &operationalinsights.AnalyticsWorkspaceArgs{
 * 			Name:              pulumi.String("example-workspace"),
 * 			Location:          example.Location,
 * 			ResourceGroupName: example.Name,
 * 			Sku:               pulumi.String("PerGB2018"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleLogAnalyticsWorkspaceOnboarding, err := sentinel.NewLogAnalyticsWorkspaceOnboarding(ctx, "example", &sentinel.LogAnalyticsWorkspaceOnboardingArgs{
 * 			WorkspaceId: exampleAnalyticsWorkspace.ID(),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = sentinel.NewAutomationRule(ctx, "example", &sentinel.AutomationRuleArgs{
 * 			Name:                    pulumi.String("56094f72-ac3f-40e7-a0c0-47bd95f70336"),
 * 			LogAnalyticsWorkspaceId: exampleLogAnalyticsWorkspaceOnboarding.WorkspaceId,
 * 			DisplayName:             pulumi.String("automation_rule1"),
 * 			Order:                   pulumi.Int(1),
 * 			ActionIncidents: sentinel.AutomationRuleActionIncidentArray{
 * 				&sentinel.AutomationRuleActionIncidentArgs{
 * 					Order:  pulumi.Int(1),
 * 					Status: pulumi.String("Active"),
 * 				},
 * 			},
 * 		})
 * 		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.operationalinsights.AnalyticsWorkspace;
 * import com.pulumi.azure.operationalinsights.AnalyticsWorkspaceArgs;
 * import com.pulumi.azure.sentinel.LogAnalyticsWorkspaceOnboarding;
 * import com.pulumi.azure.sentinel.LogAnalyticsWorkspaceOnboardingArgs;
 * import com.pulumi.azure.sentinel.AutomationRule;
 * import com.pulumi.azure.sentinel.AutomationRuleArgs;
 * import com.pulumi.azure.sentinel.inputs.AutomationRuleActionIncidentArgs;
 * 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-rg")
 *             .location("west europe")
 *             .build());
 *         var exampleAnalyticsWorkspace = new AnalyticsWorkspace("exampleAnalyticsWorkspace", AnalyticsWorkspaceArgs.builder()
 *             .name("example-workspace")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .sku("PerGB2018")
 *             .build());
 *         var exampleLogAnalyticsWorkspaceOnboarding = new LogAnalyticsWorkspaceOnboarding("exampleLogAnalyticsWorkspaceOnboarding", LogAnalyticsWorkspaceOnboardingArgs.builder()
 *             .workspaceId(exampleAnalyticsWorkspace.id())
 *             .build());
 *         var exampleAutomationRule = new AutomationRule("exampleAutomationRule", AutomationRuleArgs.builder()
 *             .name("56094f72-ac3f-40e7-a0c0-47bd95f70336")
 *             .logAnalyticsWorkspaceId(exampleLogAnalyticsWorkspaceOnboarding.workspaceId())
 *             .displayName("automation_rule1")
 *             .order(1)
 *             .actionIncidents(AutomationRuleActionIncidentArgs.builder()
 *                 .order(1)
 *                 .status("Active")
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-rg
 *       location: west europe
 *   exampleAnalyticsWorkspace:
 *     type: azure:operationalinsights:AnalyticsWorkspace
 *     name: example
 *     properties:
 *       name: example-workspace
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *       sku: PerGB2018
 *   exampleLogAnalyticsWorkspaceOnboarding:
 *     type: azure:sentinel:LogAnalyticsWorkspaceOnboarding
 *     name: example
 *     properties:
 *       workspaceId: ${exampleAnalyticsWorkspace.id}
 *   exampleAutomationRule:
 *     type: azure:sentinel:AutomationRule
 *     name: example
 *     properties:
 *       name: 56094f72-ac3f-40e7-a0c0-47bd95f70336
 *       logAnalyticsWorkspaceId: ${exampleLogAnalyticsWorkspaceOnboarding.workspaceId}
 *       displayName: automation_rule1
 *       order: 1
 *       actionIncidents:
 *         - order: 1
 *           status: Active
 * ```
 * 
 * ## Import
 * Sentinel Automation Rules can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:sentinel/automationRule:AutomationRule example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.OperationalInsights/workspaces/workspace1/providers/Microsoft.SecurityInsights/automationRules/rule1
 * ```
 */
public class AutomationRule internal constructor(
    override val javaResource: com.pulumi.azure.sentinel.AutomationRule,
) : KotlinCustomResource(javaResource, AutomationRuleMapper) {
    /**
     * One or more `action_incident` blocks as defined below.
     */
    public val actionIncidents: Output>?
        get() = javaResource.actionIncidents().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.let({ args0 ->
                        automationRuleActionIncidentToKotlin(args0)
                    })
                })
            }).orElse(null)
        })

    /**
     * One or more `action_playbook` blocks as defined below.
     * > **Note:** Either one `action_incident` block or `action_playbook` block has to be specified.
     */
    public val actionPlaybooks: Output>?
        get() = javaResource.actionPlaybooks().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.let({ args0 ->
                        automationRuleActionPlaybookToKotlin(args0)
                    })
                })
            }).orElse(null)
        })

    /**
     * A JSON array of one or more condition JSON objects as is defined [here](https://learn.microsoft.com/en-us/rest/api/securityinsights/preview/automation-rules/create-or-update?tabs=HTTP#automationruletriggeringlogic).
     */
    public val conditionJson: Output
        get() = javaResource.conditionJson().applyValue({ args0 -> args0 })

    /**
     * One or more `condition` blocks as defined below.
     * > **Note:** `condition` only supports the [`Property` condition type](https://learn.microsoft.com/en-us/rest/api/securityinsights/preview/automation-rules/create-or-update?tabs=HTTP#propertyconditionproperties). Please use `condition_json` if you want other condition types.
     */
    @Deprecated(
        message = """
  This is deprecated in favor of `condition_json`
  """,
    )
    public val conditions: Output>
        get() = javaResource.conditions().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    automationRuleConditionToKotlin(args0)
                })
            })
        })

    /**
     * The display name which should be used for this Sentinel Automation Rule.
     */
    public val displayName: Output
        get() = javaResource.displayName().applyValue({ args0 -> args0 })

    /**
     * Whether this Sentinel Automation Rule is enabled? Defaults to `true`.
     */
    public val enabled: Output?
        get() = javaResource.enabled().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The time in RFC3339 format of kind `UTC` that determines when this Automation Rule should expire and be disabled.
     */
    public val expiration: Output?
        get() = javaResource.expiration().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The ID of the Log Analytics Workspace where this Sentinel applies to. Changing this forces a new Sentinel Automation Rule to be created.
     */
    public val logAnalyticsWorkspaceId: Output
        get() = javaResource.logAnalyticsWorkspaceId().applyValue({ args0 -> args0 })

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

    /**
     * The order of this Sentinel Automation Rule. Possible values varies between `1` and `1000`.
     */
    public val order: Output
        get() = javaResource.order().applyValue({ args0 -> args0 })

    /**
     * Specifies what triggers this automation rule. Possible values are `Alerts` and `Incidents`. Defaults to `Incidents`.
     */
    public val triggersOn: Output?
        get() = javaResource.triggersOn().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Specifies when will this automation rule be triggered. Possible values are `Created` and `Updated`. Defaults to `Created`.
     */
    public val triggersWhen: Output?
        get() = javaResource.triggersWhen().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })
}

public object AutomationRuleMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.sentinel.AutomationRule::class == javaResource::class

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

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy