<gh_stars>0// *** 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>
    /// Manage role mappings. See, https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role-mapping.html
    /// 
    /// ## Example Usage
    /// 
    /// ```csharp
    /// using System.Collections.Generic;
    /// using System.Text.Json;
    /// using Pulumi;
    /// using Elasticstack = Pulumi.Elasticstack;
    /// 
    /// return await Deployment.RunAsync(() =&gt; 
    /// {
    ///     var example = new Elasticstack.SecurityRoleMapping("example", new()
    ///     {
    ///         Enabled = true,
    ///         Roles = new[]
    ///         {
    ///             "admin",
    ///         },
    ///         Rules = JsonSerializer.Serialize(new Dictionary&lt;string, object?&gt;
    ///         {
    ///             ["any"] = new[]
    ///             {
    ///                 new Dictionary&lt;string, object?&gt;
    ///                 {
    ///                     ["field"] = new Dictionary&lt;string, object?&gt;
    ///                     {
    ///                         ["username"] = "esadmin",
    ///                     },
    ///                 },
    ///                 new Dictionary&lt;string, object?&gt;
    ///                 {
    ///                     ["field"] = new Dictionary&lt;string, object?&gt;
    ///                     {
    ///                         ["groups"] = "cn=admins,dc=example,dc=com",
    ///                     },
    ///                 },
    ///             },
    ///         }),
    ///     });
    /// 
    ///     return new Dictionary&lt;string, object?&gt;
    ///     {
    ///         ["role"] = example.Name,
    ///     };
    /// });
    /// ```
    /// 
    /// ## Import
    /// 
    /// ```sh
    ///  $ pulumi import elasticstack:index/securityRoleMapping:SecurityRoleMapping my_role_mapping &lt;cluster_uuid&gt;/&lt;role mapping name&gt;
    /// ```
    /// </summary>
    [ElasticstackResourceType("elasticstack:index/securityRoleMapping:SecurityRoleMapping")]
    public partial class SecurityRoleMapping : global::Pulumi.CustomResource
    {
        /// <summary>
        /// Elasticsearch connection configuration block.
        /// </summary>
        [Output("elasticsearchConnection")]
        public Output<Outputs.SecurityRoleMappingElasticsearchConnection?> ElasticsearchConnection { get; private set; } = null!;

        /// <summary>
        /// Mappings that have `enabled` set to `false` are ignored when role mapping is performed.
        /// </summary>
        [Output("enabled")]
        public Output<bool?> Enabled { get; private set; } = null!;

        /// <summary>
        /// Additional metadata that helps define which roles are assigned to each user. Keys beginning with `_` are reserved for system usage.
        /// </summary>
        [Output("metadata")]
        public Output<string?> Metadata { get; private set; } = null!;

        /// <summary>
        /// The distinct name that identifies the role mapping, used solely as an identifier.
        /// </summary>
        [Output("name")]
        public Output<string> Name { get; private set; } = null!;

        /// <summary>
        /// A list of mustache templates that will be evaluated to determine the roles names that should granted to the users that match the role mapping rules.
        /// </summary>
        [Output("roleTemplates")]
        public Output<string?> RoleTemplates { get; private set; } = null!;

        /// <summary>
        /// A list of role names that are granted to the users that match the role mapping rules.
        /// </summary>
        [Output("roles")]
        public Output<ImmutableArray<string>> Roles { get; private set; } = null!;

        /// <summary>
        /// The rules that determine which users should be matched by the mapping. A rule is a logical condition that is expressed by using a JSON DSL.
        /// </summary>
        [Output("rules")]
        public Output<string> Rules { get; private set; } = null!;


        /// <summary>
        /// Create a SecurityRoleMapping 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 SecurityRoleMapping(string name, SecurityRoleMappingArgs args, CustomResourceOptions? options = null)
            : base("elasticstack:index/securityRoleMapping:SecurityRoleMapping", name, args ?? new SecurityRoleMappingArgs(), MakeResourceOptions(options, ""))
        {
        }

        private SecurityRoleMapping(string name, Input<string> id, SecurityRoleMappingState? state = null, CustomResourceOptions? options = null)
            : base("elasticstack:index/securityRoleMapping:SecurityRoleMapping", 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 SecurityRoleMapping 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 SecurityRoleMapping Get(string name, Input<string> id, SecurityRoleMappingState? state = null, CustomResourceOptions? options = null)
        {
            return new SecurityRoleMapping(name, id, state, options);
        }
    }

    public sealed class SecurityRoleMappingArgs : global::Pulumi.ResourceArgs
    {
        /// <summary>
        /// Elasticsearch connection configuration block.
        /// </summary>
        [Input("elasticsearchConnection")]
        public Input<Inputs.SecurityRoleMappingElasticsearchConnectionArgs>? ElasticsearchConnection { get; set; }

        /// <summary>
        /// Mappings that have `enabled` set to `false` are ignored when role mapping is performed.
        /// </summary>
        [Input("enabled")]
        public Input<bool>? Enabled { get; set; }

        /// <summary>
        /// Additional metadata that helps define which roles are assigned to each user. Keys beginning with `_` are reserved for system usage.
        /// </summary>
        [Input("metadata")]
        public Input<string>? Metadata { get; set; }

        /// <summary>
        /// The distinct name that identifies the role mapping, used solely as an identifier.
        /// </summary>
        [Input("name")]
        public Input<string>? Name { get; set; }

        /// <summary>
        /// A list of mustache templates that will be evaluated to determine the roles names that should granted to the users that match the role mapping rules.
        /// </summary>
        [Input("roleTemplates")]
        public Input<string>? RoleTemplates { get; set; }

        [Input("roles")]
        private InputList<string>? _roles;

        /// <summary>
        /// A list of role names that are granted to the users that match the role mapping rules.
        /// </summary>
        public InputList<string> Roles
        {
            get => _roles ?? (_roles = new InputList<string>());
            set => _roles = value;
        }

        /// <summary>
        /// The rules that determine which users should be matched by the mapping. A rule is a logical condition that is expressed by using a JSON DSL.
        /// </summary>
        [Input("rules", required: true)]
        public Input<string> Rules { get; set; } = null!;

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

    public sealed class SecurityRoleMappingState : global::Pulumi.ResourceArgs
    {
        /// <summary>
        /// Elasticsearch connection configuration block.
        /// </summary>
        [Input("elasticsearchConnection")]
        public Input<Inputs.SecurityRoleMappingElasticsearchConnectionGetArgs>? ElasticsearchConnection { get; set; }

        /// <summary>
        /// Mappings that have `enabled` set to `false` are ignored when role mapping is performed.
        /// </summary>
        [Input("enabled")]
        public Input<bool>? Enabled { get; set; }

        /// <summary>
        /// Additional metadata that helps define which roles are assigned to each user. Keys beginning with `_` are reserved for system usage.
        /// </summary>
        [Input("metadata")]
        public Input<string>? Metadata { get; set; }

        /// <summary>
        /// The distinct name that identifies the role mapping, used solely as an identifier.
        /// </summary>
        [Input("name")]
        public Input<string>? Name { get; set; }

        /// <summary>
        /// A list of mustache templates that will be evaluated to determine the roles names that should granted to the users that match the role mapping rules.
        /// </summary>
        [Input("roleTemplates")]
        public Input<string>? RoleTemplates { get; set; }

        [Input("roles")]
        private InputList<string>? _roles;

        /// <summary>
        /// A list of role names that are granted to the users that match the role mapping rules.
        /// </summary>
        public InputList<string> Roles
        {
            get => _roles ?? (_roles = new InputList<string>());
            set => _roles = value;
        }

        /// <summary>
        /// The rules that determine which users should be matched by the mapping. A rule is a logical condition that is expressed by using a JSON DSL.
        /// </summary>
        [Input("rules")]
        public Input<string>? Rules { get; set; }

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