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

com.pulumi.azure.loganalytics.kotlin.SavedSearch.kt Maven / Gradle / Ivy

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

package com.pulumi.azure.loganalytics.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.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map

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

    public var args: SavedSearchArgs = SavedSearchArgs()

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

/**
 * Manages a Log Analytics (formally Operational Insights) Saved Search.
 * ## 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 exampleAnalyticsWorkspace = new azure.operationalinsights.AnalyticsWorkspace("example", {
 *     name: "acctest-01",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     sku: "PerGB2018",
 *     retentionInDays: 30,
 * });
 * const exampleSavedSearch = new azure.loganalytics.SavedSearch("example", {
 *     name: "exampleSavedSearch",
 *     logAnalyticsWorkspaceId: exampleAnalyticsWorkspace.id,
 *     category: "exampleCategory",
 *     displayName: "exampleDisplayName",
 *     query: "exampleQuery",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="example-resources",
 *     location="West Europe")
 * example_analytics_workspace = azure.operationalinsights.AnalyticsWorkspace("example",
 *     name="acctest-01",
 *     location=example.location,
 *     resource_group_name=example.name,
 *     sku="PerGB2018",
 *     retention_in_days=30)
 * example_saved_search = azure.loganalytics.SavedSearch("example",
 *     name="exampleSavedSearch",
 *     log_analytics_workspace_id=example_analytics_workspace.id,
 *     category="exampleCategory",
 *     display_name="exampleDisplayName",
 *     query="exampleQuery")
 * ```
 * ```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 exampleAnalyticsWorkspace = new Azure.OperationalInsights.AnalyticsWorkspace("example", new()
 *     {
 *         Name = "acctest-01",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *         Sku = "PerGB2018",
 *         RetentionInDays = 30,
 *     });
 *     var exampleSavedSearch = new Azure.LogAnalytics.SavedSearch("example", new()
 *     {
 *         Name = "exampleSavedSearch",
 *         LogAnalyticsWorkspaceId = exampleAnalyticsWorkspace.Id,
 *         Category = "exampleCategory",
 *         DisplayName = "exampleDisplayName",
 *         Query = "exampleQuery",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/loganalytics"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/operationalinsights"
 * 	"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
 * 		}
 * 		exampleAnalyticsWorkspace, err := operationalinsights.NewAnalyticsWorkspace(ctx, "example", &operationalinsights.AnalyticsWorkspaceArgs{
 * 			Name:              pulumi.String("acctest-01"),
 * 			Location:          example.Location,
 * 			ResourceGroupName: example.Name,
 * 			Sku:               pulumi.String("PerGB2018"),
 * 			RetentionInDays:   pulumi.Int(30),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = loganalytics.NewSavedSearch(ctx, "example", &loganalytics.SavedSearchArgs{
 * 			Name:                    pulumi.String("exampleSavedSearch"),
 * 			LogAnalyticsWorkspaceId: exampleAnalyticsWorkspace.ID(),
 * 			Category:                pulumi.String("exampleCategory"),
 * 			DisplayName:             pulumi.String("exampleDisplayName"),
 * 			Query:                   pulumi.String("exampleQuery"),
 * 		})
 * 		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.loganalytics.SavedSearch;
 * import com.pulumi.azure.loganalytics.SavedSearchArgs;
 * 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 exampleAnalyticsWorkspace = new AnalyticsWorkspace("exampleAnalyticsWorkspace", AnalyticsWorkspaceArgs.builder()
 *             .name("acctest-01")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .sku("PerGB2018")
 *             .retentionInDays(30)
 *             .build());
 *         var exampleSavedSearch = new SavedSearch("exampleSavedSearch", SavedSearchArgs.builder()
 *             .name("exampleSavedSearch")
 *             .logAnalyticsWorkspaceId(exampleAnalyticsWorkspace.id())
 *             .category("exampleCategory")
 *             .displayName("exampleDisplayName")
 *             .query("exampleQuery")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-resources
 *       location: West Europe
 *   exampleAnalyticsWorkspace:
 *     type: azure:operationalinsights:AnalyticsWorkspace
 *     name: example
 *     properties:
 *       name: acctest-01
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *       sku: PerGB2018
 *       retentionInDays: 30
 *   exampleSavedSearch:
 *     type: azure:loganalytics:SavedSearch
 *     name: example
 *     properties:
 *       name: exampleSavedSearch
 *       logAnalyticsWorkspaceId: ${exampleAnalyticsWorkspace.id}
 *       category: exampleCategory
 *       displayName: exampleDisplayName
 *       query: exampleQuery
 * ```
 * 
 * ## Import
 * Log Analytics Saved Searches can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:loganalytics/savedSearch:SavedSearch search1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/savedSearches/search1
 * ```
 */
public class SavedSearch internal constructor(
    override val javaResource: com.pulumi.azure.loganalytics.SavedSearch,
) : KotlinCustomResource(javaResource, SavedSearchMapper) {
    /**
     * The category that the Saved Search will be listed under. Changing this forces a new resource to be created.
     */
    public val category: Output
        get() = javaResource.category().applyValue({ args0 -> args0 })

    /**
     * The name that Saved Search will be displayed as. Changing this forces a new resource to be created.
     */
    public val displayName: Output
        get() = javaResource.displayName().applyValue({ args0 -> args0 })

    /**
     * The function alias if the query serves as a function. Changing this forces a new resource to be created.
     */
    public val functionAlias: Output?
        get() = javaResource.functionAlias().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The function parameters if the query serves as a function. Changing this forces a new resource to be created. For more examples and proper syntax please refer to [this document](https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/functions/user-defined-functions).
     */
    public val functionParameters: Output>?
        get() = javaResource.functionParameters().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 -> args0 })
            }).orElse(null)
        })

    /**
     * Specifies the ID of the Log Analytics Workspace that the Saved Search will be associated with. Changing this forces a new resource to be created.
     */
    public val logAnalyticsWorkspaceId: Output
        get() = javaResource.logAnalyticsWorkspaceId().applyValue({ args0 -> args0 })

    /**
     * Specifies the name of the Log Analytics Saved Search. Changing this forces a new resource to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

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

    /**
     * A mapping of tags which should be assigned to the Logs Analytics Saved Search. Changing this forces a new resource to be created.
     */
    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 SavedSearchMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.loganalytics.SavedSearch::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy