<reponame>zlepper/pulumi-elasticstack<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>
    /// Creates or updates a snapshot lifecycle policy. See, https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put-policy.html
    /// 
    /// ## Example Usage
    /// 
    /// ```csharp
    /// using System.Collections.Generic;
    /// using Pulumi;
    /// using Elasticstack = Pulumi.Elasticstack;
    /// 
    /// return await Deployment.RunAsync(() =&gt; 
    /// {
    ///     // create a repository for snapshots
    ///     var repo = new Elasticstack.SnapshotRepository("repo", new()
    ///     {
    ///         Fs = new Elasticstack.Inputs.SnapshotRepositoryFsArgs
    ///         {
    ///             Location = "/tmp/snapshots",
    ///             Compress = true,
    ///             MaxRestoreBytesPerSec = "20mb",
    ///         },
    ///     });
    /// 
    ///     // create a SLM policy and use the above created repository
    ///     var slmPolicy = new Elasticstack.SnapshotLifecycle("slmPolicy", new()
    ///     {
    ///         Schedule = "0 30 1 * * ?",
    ///         SnapshotName = "&lt;daily-snap-{now/d}&gt;",
    ///         Repository = repo.Name,
    ///         Indices = new[]
    ///         {
    ///             "data-*",
    ///             "important",
    ///         },
    ///         IgnoreUnavailable = false,
    ///         IncludeGlobalState = false,
    ///         ExpireAfter = "30d",
    ///         MinCount = 5,
    ///         MaxCount = 50,
    ///     });
    /// 
    /// });
    /// ```
    /// 
    /// ## Import
    /// 
    /// ```sh
    ///  $ pulumi import elasticstack:index/snapshotLifecycle:SnapshotLifecycle my_policy &lt;cluster_uuid&gt;/&lt;slm policy name&gt;
    /// ```
    /// </summary>
    [ElasticstackResourceType("elasticstack:index/snapshotLifecycle:SnapshotLifecycle")]
    public partial class SnapshotLifecycle : global::Pulumi.CustomResource
    {
        /// <summary>
        /// Elasticsearch connection configuration block.
        /// </summary>
        [Output("elasticsearchConnection")]
        public Output<Outputs.SnapshotLifecycleElasticsearchConnection?> ElasticsearchConnection { get; private set; } = null!;

        /// <summary>
        /// Determines how wildcard patterns in the `indices` parameter match data streams and indices. Supports comma-separated values, such as `closed,hidden`.
        /// </summary>
        [Output("expandWildcards")]
        public Output<string?> ExpandWildcards { get; private set; } = null!;

        /// <summary>
        /// Time period after which a snapshot is considered expired and eligible for deletion.
        /// </summary>
        [Output("expireAfter")]
        public Output<string?> ExpireAfter { get; private set; } = null!;

        /// <summary>
        /// Feature states to include in the snapshot.
        /// </summary>
        [Output("featureStates")]
        public Output<ImmutableArray<string>> FeatureStates { get; private set; } = null!;

        /// <summary>
        /// If `false`, the snapshot fails if any data stream or index in indices is missing or closed. If `true`, the snapshot ignores missing or closed data streams and indices.
        /// </summary>
        [Output("ignoreUnavailable")]
        public Output<bool?> IgnoreUnavailable { get; private set; } = null!;

        /// <summary>
        /// If `true`, include the cluster state in the snapshot.
        /// </summary>
        [Output("includeGlobalState")]
        public Output<bool?> IncludeGlobalState { get; private set; } = null!;

        /// <summary>
        /// Comma-separated list of data streams and indices to include in the snapshot.
        /// </summary>
        [Output("indices")]
        public Output<ImmutableArray<string>> Indices { get; private set; } = null!;

        /// <summary>
        /// Maximum number of snapshots to retain, even if the snapshots have not yet expired.
        /// </summary>
        [Output("maxCount")]
        public Output<int?> MaxCount { get; private set; } = null!;

        /// <summary>
        /// Attaches arbitrary metadata to the snapshot.
        /// </summary>
        [Output("metadata")]
        public Output<string> Metadata { get; private set; } = null!;

        /// <summary>
        /// Minimum number of snapshots to retain, even if the snapshots have expired.
        /// </summary>
        [Output("minCount")]
        public Output<int?> MinCount { get; private set; } = null!;

        /// <summary>
        /// ID for the snapshot lifecycle policy you want to create or update.
        /// </summary>
        [Output("name")]
        public Output<string> Name { get; private set; } = null!;

        /// <summary>
        /// If `false`, the entire snapshot will fail if one or more indices included in the snapshot do not have all primary shards available.
        /// </summary>
        [Output("partial")]
        public Output<bool?> Partial { get; private set; } = null!;

        /// <summary>
        /// Repository used to store snapshots created by this policy.
        /// </summary>
        [Output("repository")]
        public Output<string> Repository { get; private set; } = null!;

        /// <summary>
        /// Periodic or absolute schedule at which the policy creates snapshots.
        /// </summary>
        [Output("schedule")]
        public Output<string> Schedule { get; private set; } = null!;

        /// <summary>
        /// Name automatically assigned to each snapshot created by the policy.
        /// </summary>
        [Output("snapshotName")]
        public Output<string?> SnapshotName { get; private set; } = null!;


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

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

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

        /// <summary>
        /// Determines how wildcard patterns in the `indices` parameter match data streams and indices. Supports comma-separated values, such as `closed,hidden`.
        /// </summary>
        [Input("expandWildcards")]
        public Input<string>? ExpandWildcards { get; set; }

        /// <summary>
        /// Time period after which a snapshot is considered expired and eligible for deletion.
        /// </summary>
        [Input("expireAfter")]
        public Input<string>? ExpireAfter { get; set; }

        [Input("featureStates")]
        private InputList<string>? _featureStates;

        /// <summary>
        /// Feature states to include in the snapshot.
        /// </summary>
        public InputList<string> FeatureStates
        {
            get => _featureStates ?? (_featureStates = new InputList<string>());
            set => _featureStates = value;
        }

        /// <summary>
        /// If `false`, the snapshot fails if any data stream or index in indices is missing or closed. If `true`, the snapshot ignores missing or closed data streams and indices.
        /// </summary>
        [Input("ignoreUnavailable")]
        public Input<bool>? IgnoreUnavailable { get; set; }

        /// <summary>
        /// If `true`, include the cluster state in the snapshot.
        /// </summary>
        [Input("includeGlobalState")]
        public Input<bool>? IncludeGlobalState { get; set; }

        [Input("indices")]
        private InputList<string>? _indices;

        /// <summary>
        /// Comma-separated list of data streams and indices to include in the snapshot.
        /// </summary>
        public InputList<string> Indices
        {
            get => _indices ?? (_indices = new InputList<string>());
            set => _indices = value;
        }

        /// <summary>
        /// Maximum number of snapshots to retain, even if the snapshots have not yet expired.
        /// </summary>
        [Input("maxCount")]
        public Input<int>? MaxCount { get; set; }

        /// <summary>
        /// Attaches arbitrary metadata to the snapshot.
        /// </summary>
        [Input("metadata")]
        public Input<string>? Metadata { get; set; }

        /// <summary>
        /// Minimum number of snapshots to retain, even if the snapshots have expired.
        /// </summary>
        [Input("minCount")]
        public Input<int>? MinCount { get; set; }

        /// <summary>
        /// ID for the snapshot lifecycle policy you want to create or update.
        /// </summary>
        [Input("name")]
        public Input<string>? Name { get; set; }

        /// <summary>
        /// If `false`, the entire snapshot will fail if one or more indices included in the snapshot do not have all primary shards available.
        /// </summary>
        [Input("partial")]
        public Input<bool>? Partial { get; set; }

        /// <summary>
        /// Repository used to store snapshots created by this policy.
        /// </summary>
        [Input("repository", required: true)]
        public Input<string> Repository { get; set; } = null!;

        /// <summary>
        /// Periodic or absolute schedule at which the policy creates snapshots.
        /// </summary>
        [Input("schedule", required: true)]
        public Input<string> Schedule { get; set; } = null!;

        /// <summary>
        /// Name automatically assigned to each snapshot created by the policy.
        /// </summary>
        [Input("snapshotName")]
        public Input<string>? SnapshotName { get; set; }

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

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

        /// <summary>
        /// Determines how wildcard patterns in the `indices` parameter match data streams and indices. Supports comma-separated values, such as `closed,hidden`.
        /// </summary>
        [Input("expandWildcards")]
        public Input<string>? ExpandWildcards { get; set; }

        /// <summary>
        /// Time period after which a snapshot is considered expired and eligible for deletion.
        /// </summary>
        [Input("expireAfter")]
        public Input<string>? ExpireAfter { get; set; }

        [Input("featureStates")]
        private InputList<string>? _featureStates;

        /// <summary>
        /// Feature states to include in the snapshot.
        /// </summary>
        public InputList<string> FeatureStates
        {
            get => _featureStates ?? (_featureStates = new InputList<string>());
            set => _featureStates = value;
        }

        /// <summary>
        /// If `false`, the snapshot fails if any data stream or index in indices is missing or closed. If `true`, the snapshot ignores missing or closed data streams and indices.
        /// </summary>
        [Input("ignoreUnavailable")]
        public Input<bool>? IgnoreUnavailable { get; set; }

        /// <summary>
        /// If `true`, include the cluster state in the snapshot.
        /// </summary>
        [Input("includeGlobalState")]
        public Input<bool>? IncludeGlobalState { get; set; }

        [Input("indices")]
        private InputList<string>? _indices;

        /// <summary>
        /// Comma-separated list of data streams and indices to include in the snapshot.
        /// </summary>
        public InputList<string> Indices
        {
            get => _indices ?? (_indices = new InputList<string>());
            set => _indices = value;
        }

        /// <summary>
        /// Maximum number of snapshots to retain, even if the snapshots have not yet expired.
        /// </summary>
        [Input("maxCount")]
        public Input<int>? MaxCount { get; set; }

        /// <summary>
        /// Attaches arbitrary metadata to the snapshot.
        /// </summary>
        [Input("metadata")]
        public Input<string>? Metadata { get; set; }

        /// <summary>
        /// Minimum number of snapshots to retain, even if the snapshots have expired.
        /// </summary>
        [Input("minCount")]
        public Input<int>? MinCount { get; set; }

        /// <summary>
        /// ID for the snapshot lifecycle policy you want to create or update.
        /// </summary>
        [Input("name")]
        public Input<string>? Name { get; set; }

        /// <summary>
        /// If `false`, the entire snapshot will fail if one or more indices included in the snapshot do not have all primary shards available.
        /// </summary>
        [Input("partial")]
        public Input<bool>? Partial { get; set; }

        /// <summary>
        /// Repository used to store snapshots created by this policy.
        /// </summary>
        [Input("repository")]
        public Input<string>? Repository { get; set; }

        /// <summary>
        /// Periodic or absolute schedule at which the policy creates snapshots.
        /// </summary>
        [Input("schedule")]
        public Input<string>? Schedule { get; set; }

        /// <summary>
        /// Name automatically assigned to each snapshot created by the policy.
        /// </summary>
        [Input("snapshotName")]
        public Input<string>? SnapshotName { get; set; }

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