// *** 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 an API key for access without requiring basic authentication. See, https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html
    /// 
    /// ## Example Usage
    /// 
    /// ```csharp
    /// using System.Collections.Generic;
    /// using System.Text.Json;
    /// using Pulumi;
    /// using Elasticstack = Pulumi.Elasticstack;
    /// 
    /// return await Deployment.RunAsync(() =&gt; 
    /// {
    ///     var apiKeySecurityApiKey = new Elasticstack.SecurityApiKey("apiKeySecurityApiKey", new()
    ///     {
    ///         RoleDescriptors = JsonSerializer.Serialize(new Dictionary&lt;string, object?&gt;
    ///         {
    ///             ["role-a"] = new Dictionary&lt;string, object?&gt;
    ///             {
    ///                 ["cluster"] = new[]
    ///                 {
    ///                     "all",
    ///                 },
    ///                 ["indices"] = new[]
    ///                 {
    ///                     new Dictionary&lt;string, object?&gt;
    ///                     {
    ///                         ["names"] = new[]
    ///                         {
    ///                             "index-a*",
    ///                         },
    ///                         ["privileges"] = new[]
    ///                         {
    ///                             "read",
    ///                         },
    ///                     },
    ///                 },
    ///             },
    ///         }),
    ///         Expiration = "1d",
    ///         Metadata = JsonSerializer.Serialize(new Dictionary&lt;string, object?&gt;
    ///         {
    ///             ["env"] = "testing",
    ///             ["open"] = false,
    ///             ["number"] = 49,
    ///         }),
    ///     });
    /// 
    ///     return new Dictionary&lt;string, object?&gt;
    ///     {
    ///         ["apiKey"] = apiKeySecurityApiKey,
    ///     };
    /// });
    /// ```
    /// 
    /// ## Import
    /// 
    /// Import is not supported due to the generated API key only being visible on create.
    /// </summary>
    [ElasticstackResourceType("elasticstack:index/securityApiKey:SecurityApiKey")]
    public partial class SecurityApiKey : global::Pulumi.CustomResource
    {
        /// <summary>
        /// Generated API Key.
        /// </summary>
        [Output("apiKey")]
        public Output<string> ApiKey { get; private set; } = null!;

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

        /// <summary>
        /// API key credentials which is the Base64-encoding of the UTF-8 representation of the id and api_key joined by a colon (:).
        /// </summary>
        [Output("encoded")]
        public Output<string> Encoded { get; private set; } = null!;

        /// <summary>
        /// Expiration time for the API key. By default, API keys never expire.
        /// </summary>
        [Output("expiration")]
        public Output<string?> Expiration { get; private set; } = null!;

        /// <summary>
        /// Expiration time in milliseconds for the API key. By default, API keys never expire.
        /// </summary>
        [Output("expirationTimestamp")]
        public Output<int> ExpirationTimestamp { get; private set; } = null!;

        /// <summary>
        /// Arbitrary metadata that you want to associate with the API key.
        /// </summary>
        [Output("metadata")]
        public Output<string> Metadata { get; private set; } = null!;

        /// <summary>
        /// Specifies the name for this API key.
        /// </summary>
        [Output("name")]
        public Output<string> Name { get; private set; } = null!;

        /// <summary>
        /// Role descriptors for this API key.
        /// </summary>
        [Output("roleDescriptors")]
        public Output<string?> RoleDescriptors { get; private set; } = null!;


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

        private SecurityApiKey(string name, Input<string> id, SecurityApiKeyState? state = null, CustomResourceOptions? options = null)
            : base("elasticstack:index/securityApiKey:SecurityApiKey", 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",
                AdditionalSecretOutputs =
                {
                    "apiKey",
                    "encoded",
                },
            };
            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 SecurityApiKey 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 SecurityApiKey Get(string name, Input<string> id, SecurityApiKeyState? state = null, CustomResourceOptions? options = null)
        {
            return new SecurityApiKey(name, id, state, options);
        }
    }

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

        /// <summary>
        /// Expiration time for the API key. By default, API keys never expire.
        /// </summary>
        [Input("expiration")]
        public Input<string>? Expiration { get; set; }

        /// <summary>
        /// Arbitrary metadata that you want to associate with the API key.
        /// </summary>
        [Input("metadata")]
        public Input<string>? Metadata { get; set; }

        /// <summary>
        /// Specifies the name for this API key.
        /// </summary>
        [Input("name")]
        public Input<string>? Name { get; set; }

        /// <summary>
        /// Role descriptors for this API key.
        /// </summary>
        [Input("roleDescriptors")]
        public Input<string>? RoleDescriptors { get; set; }

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

    public sealed class SecurityApiKeyState : global::Pulumi.ResourceArgs
    {
        [Input("apiKey")]
        private Input<string>? _apiKey;

        /// <summary>
        /// Generated API Key.
        /// </summary>
        public Input<string>? ApiKey
        {
            get => _apiKey;
            set
            {
                var emptySecret = Output.CreateSecret(0);
                _apiKey = Output.Tuple<Input<string>?, int>(value, emptySecret).Apply(t => t.Item1);
            }
        }

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

        [Input("encoded")]
        private Input<string>? _encoded;

        /// <summary>
        /// API key credentials which is the Base64-encoding of the UTF-8 representation of the id and api_key joined by a colon (:).
        /// </summary>
        public Input<string>? Encoded
        {
            get => _encoded;
            set
            {
                var emptySecret = Output.CreateSecret(0);
                _encoded = Output.Tuple<Input<string>?, int>(value, emptySecret).Apply(t => t.Item1);
            }
        }

        /// <summary>
        /// Expiration time for the API key. By default, API keys never expire.
        /// </summary>
        [Input("expiration")]
        public Input<string>? Expiration { get; set; }

        /// <summary>
        /// Expiration time in milliseconds for the API key. By default, API keys never expire.
        /// </summary>
        [Input("expirationTimestamp")]
        public Input<int>? ExpirationTimestamp { get; set; }

        /// <summary>
        /// Arbitrary metadata that you want to associate with the API key.
        /// </summary>
        [Input("metadata")]
        public Input<string>? Metadata { get; set; }

        /// <summary>
        /// Specifies the name for this API key.
        /// </summary>
        [Input("name")]
        public Input<string>? Name { get; set; }

        /// <summary>
        /// Role descriptors for this API key.
        /// </summary>
        [Input("roleDescriptors")]
        public Input<string>? RoleDescriptors { get; set; }

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