// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Pulumi.Serialization;

namespace Pulumi.Elasticstack
{
    /// <summary>
    /// Creates or updates a stored script or search template. See https://www.elastic.co/guide/en/elasticsearch/reference/current/create-stored-script-api.html
    /// 
    /// ## Example Usage
    /// 
    /// ```csharp
    /// using System.Collections.Generic;
    /// using System.Text.Json;
    /// using Pulumi;
    /// using Elasticstack = Pulumi.Elasticstack;
    /// 
    /// return await Deployment.RunAsync(() =&gt; 
    /// {
    ///     var myScript = new Elasticstack.Script("myScript", new()
    ///     {
    ///         ScriptId = "my_script",
    ///         Lang = "painless",
    ///         Source = "Math.log(_score * 2) + params['my_modifier']",
    ///         Context = "score",
    ///     });
    /// 
    ///     var mySearchTemplate = new Elasticstack.Script("mySearchTemplate", new()
    ///     {
    ///         ScriptId = "my_search_template",
    ///         Lang = "mustache",
    ///         Source = JsonSerializer.Serialize(new Dictionary&lt;string, object?&gt;
    ///         {
    ///             ["query"] = new Dictionary&lt;string, object?&gt;
    ///             {
    ///                 ["match"] = new Dictionary&lt;string, object?&gt;
    ///                 {
    ///                     ["message"] = "{{query_string}}",
    ///                 },
    ///             },
    ///             ["from"] = "{{from}}",
    ///             ["size"] = "{{size}}",
    ///         }),
    ///         Params = JsonSerializer.Serialize(new Dictionary&lt;string, object?&gt;
    ///         {
    ///             ["query_string"] = "My query string",
    ///         }),
    ///     });
    /// 
    /// });
    /// ```
    /// 
    /// ## Import
    /// 
    /// ```sh
    ///  $ pulumi import elasticstack:index/script:Script my_script &lt;cluster_uuid&gt;/&lt;script id&gt;
    /// ```
    /// </summary>
    [ElasticstackResourceType("elasticstack:index/script:Script")]
    public partial class Script : global::Pulumi.CustomResource
    {
        /// <summary>
        /// Context in which the script or search template should run.
        /// </summary>
        [Output("context")]
        public Output<string?> Context { get; private set; } = null!;

        /// <summary>
        /// Elasticsearch connection configuration block.
        /// </summary>
        [Output("elasticsearchConnection")]
        public Output<Outputs.ScriptElasticsearchConnection?> ElasticsearchConnection { get; private set; } = null!;

        /// <summary>
        /// Script language. For search templates, use `mustache`.
        /// </summary>
        [Output("lang")]
        public Output<string> Lang { get; private set; } = null!;

        /// <summary>
        /// Parameters for the script or search template.
        /// </summary>
        [Output("params")]
        public Output<string?> Params { get; private set; } = null!;

        /// <summary>
        /// Identifier for the stored script. Must be unique within the cluster.
        /// </summary>
        [Output("scriptId")]
        public Output<string> ScriptId { get; private set; } = null!;

        /// <summary>
        /// For scripts, a string containing the script. For search templates, an object containing the search template.
        /// </summary>
        [Output("source")]
        public Output<string> Source { get; private set; } = null!;


        /// <summary>
        /// Create a Script resource with the given unique name, arguments, and options.
        /// </summary>
        ///
        /// <param name="name">The unique name of the resource</param>
        /// <param name="args">The arguments used to populate this resource's properties</param>
        /// <param name="options">A bag of options that control this resource's behavior</param>
        public Script(string name, ScriptArgs args, CustomResourceOptions? options = null)
            : base("elasticstack:index/script:Script", name, args ?? new ScriptArgs(), MakeResourceOptions(options, ""))
        {
        }

        private Script(string name, Input<string> id, ScriptState? state = null, CustomResourceOptions? options = null)
            : base("elasticstack:index/script:Script", name, state, MakeResourceOptions(options, id))
        {
        }

        private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? options, Input<string>? id)
        {
            var defaultOptions = new CustomResourceOptions
            {
                Version = Utilities.Version,
                PluginDownloadURL = "github://api.github.com/zlepper",
            };
            var merged = CustomResourceOptions.Merge(defaultOptions, options);
            // Override the ID if one was specified for consistency with other language SDKs.
            merged.Id = id ?? merged.Id;
            return merged;
        }
        /// <summary>
        /// Get an existing Script resource's state with the given name, ID, and optional extra
        /// properties used to qualify the lookup.
        /// </summary>
        ///
        /// <param name="name">The unique name of the resulting resource.</param>
        /// <param name="id">The unique provider ID of the resource to lookup.</param>
        /// <param name="state">Any extra arguments used during the lookup.</param>
        /// <param name="options">A bag of options that control this resource's behavior</param>
        public static Script Get(string name, Input<string> id, ScriptState? state = null, CustomResourceOptions? options = null)
        {
            return new Script(name, id, state, options);
        }
    }

    public sealed class ScriptArgs : global::Pulumi.ResourceArgs
    {
        /// <summary>
        /// Context in which the script or search template should run.
        /// </summary>
        [Input("context")]
        public Input<string>? Context { get; set; }

        /// <summary>
        /// Elasticsearch connection configuration block.
        /// </summary>
        [Input("elasticsearchConnection")]
        public Input<Inputs.ScriptElasticsearchConnectionArgs>? ElasticsearchConnection { get; set; }

        /// <summary>
        /// Script language. For search templates, use `mustache`.
        /// </summary>
        [Input("lang", required: true)]
        public Input<string> Lang { get; set; } = null!;

        /// <summary>
        /// Parameters for the script or search template.
        /// </summary>
        [Input("params")]
        public Input<string>? Params { get; set; }

        /// <summary>
        /// Identifier for the stored script. Must be unique within the cluster.
        /// </summary>
        [Input("scriptId", required: true)]
        public Input<string> ScriptId { get; set; } = null!;

        /// <summary>
        /// For scripts, a string containing the script. For search templates, an object containing the search template.
        /// </summary>
        [Input("source", required: true)]
        public Input<string> Source { get; set; } = null!;

        public ScriptArgs()
        {
        }
        public static new ScriptArgs Empty => new ScriptArgs();
    }

    public sealed class ScriptState : global::Pulumi.ResourceArgs
    {
        /// <summary>
        /// Context in which the script or search template should run.
        /// </summary>
        [Input("context")]
        public Input<string>? Context { get; set; }

        /// <summary>
        /// Elasticsearch connection configuration block.
        /// </summary>
        [Input("elasticsearchConnection")]
        public Input<Inputs.ScriptElasticsearchConnectionGetArgs>? ElasticsearchConnection { get; set; }

        /// <summary>
        /// Script language. For search templates, use `mustache`.
        /// </summary>
        [Input("lang")]
        public Input<string>? Lang { get; set; }

        /// <summary>
        /// Parameters for the script or search template.
        /// </summary>
        [Input("params")]
        public Input<string>? Params { get; set; }

        /// <summary>
        /// Identifier for the stored script. Must be unique within the cluster.
        /// </summary>
        [Input("scriptId")]
        public Input<string>? ScriptId { get; set; }

        /// <summary>
        /// For scripts, a string containing the script. For search templates, an object containing the search template.
        /// </summary>
        [Input("source")]
        public Input<string>? Source { get; set; }

        public ScriptState()
        {
        }
        public static new ScriptState Empty => new ScriptState();
    }
}
