<reponame>Regrau/pulumi-yandex<filename>sdk/dotnet/MdbPostgresqlUser.cs// *** 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.Yandex
{
    /// <summary>
    /// Manages a PostgreSQL user within the Yandex.Cloud. For more information, see
    /// [the official documentation](https://cloud.yandex.com/docs/managed-postgresql/).
    /// 
    /// ## Example Usage
    /// 
    /// ```csharp
    /// using System.Collections.Generic;
    /// using Pulumi;
    /// using Yandex = Pulumi.Yandex;
    /// 
    /// return await Deployment.RunAsync(() =&gt; 
    /// {
    ///     var fooVpcNetwork = new Yandex.VpcNetwork("fooVpcNetwork");
    /// 
    ///     var fooVpcSubnet = new Yandex.VpcSubnet("fooVpcSubnet", new()
    ///     {
    ///         Zone = "ru-central1-a",
    ///         NetworkId = fooVpcNetwork.Id,
    ///         V4CidrBlocks = new[]
    ///         {
    ///             "10.5.0.0/24",
    ///         },
    ///     });
    /// 
    ///     var fooMdbPostgresqlCluster = new Yandex.MdbPostgresqlCluster("fooMdbPostgresqlCluster", new()
    ///     {
    ///         Environment = "PRESTABLE",
    ///         NetworkId = fooVpcNetwork.Id,
    ///         Config = new Yandex.Inputs.MdbPostgresqlClusterConfigArgs
    ///         {
    ///             Version = "15",
    ///             Resources = new Yandex.Inputs.MdbPostgresqlClusterConfigResourcesArgs
    ///             {
    ///                 ResourcePresetId = "s2.micro",
    ///                 DiskTypeId = "network-ssd",
    ///                 DiskSize = 16,
    ///             },
    ///         },
    ///         Hosts = new[]
    ///         {
    ///             new Yandex.Inputs.MdbPostgresqlClusterHostArgs
    ///             {
    ///                 Zone = "ru-central1-a",
    ///                 SubnetId = fooVpcSubnet.Id,
    ///             },
    ///         },
    ///     });
    /// 
    ///     var foomdbPostgresqlUser = new Yandex.MdbPostgresqlUser("foomdbPostgresqlUser", new()
    ///     {
    ///         ClusterId = fooMdbPostgresqlCluster.Id,
    ///         Password = "password",
    ///         ConnLimit = 50,
    ///         Settings = 
    ///         {
    ///             { "default_transaction_isolation", "read committed" },
    ///             { "log_min_duration_statement", "5000" },
    ///         },
    ///     });
    /// 
    /// });
    /// ```
    /// 
    /// ## Import
    /// 
    /// A PostgreSQL user can be imported using the following format
    /// 
    /// ```sh
    ///  $ pulumi import yandex:index/mdbPostgresqlUser:mdbPostgresqlUser foo {{cluster_id}}:{{username}}
    /// ```
    /// </summary>
    [YandexResourceType("yandex:index/mdbPostgresqlUser:mdbPostgresqlUser")]
    public partial class MdbPostgresqlUser : global::Pulumi.CustomResource
    {
        [Output("clusterId")]
        public Output<string> ClusterId { get; private set; } = null!;

        /// <summary>
        /// The maximum number of connections per user. (Default 50)
        /// </summary>
        [Output("connLimit")]
        public Output<int> ConnLimit { get; private set; } = null!;

        /// <summary>
        /// List of the user's grants.
        /// </summary>
        [Output("grants")]
        public Output<ImmutableArray<string>> Grants { get; private set; } = null!;

        /// <summary>
        /// User's ability to login.
        /// </summary>
        [Output("login")]
        public Output<bool?> Login { get; private set; } = null!;

        /// <summary>
        /// The name of the user.
        /// </summary>
        [Output("name")]
        public Output<string> Name { get; private set; } = null!;

        /// <summary>
        /// The password of the user.
        /// </summary>
        [Output("password")]
        public Output<string> Password { get; private set; } = null!;

        /// <summary>
        /// Set of permissions granted to the user. The structure is documented below.
        /// </summary>
        [Output("permissions")]
        public Output<ImmutableArray<Outputs.MdbPostgresqlUserPermission>> Permissions { get; private set; } = null!;

        /// <summary>
        /// Map of user settings. List of settings is documented below.
        /// </summary>
        [Output("settings")]
        public Output<ImmutableDictionary<string, string>> Settings { get; private set; } = null!;


        /// <summary>
        /// Create a MdbPostgresqlUser 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 MdbPostgresqlUser(string name, MdbPostgresqlUserArgs args, CustomResourceOptions? options = null)
            : base("yandex:index/mdbPostgresqlUser:mdbPostgresqlUser", name, args ?? new MdbPostgresqlUserArgs(), MakeResourceOptions(options, ""))
        {
        }

        private MdbPostgresqlUser(string name, Input<string> id, MdbPostgresqlUserState? state = null, CustomResourceOptions? options = null)
            : base("yandex:index/mdbPostgresqlUser:mdbPostgresqlUser", name, state, MakeResourceOptions(options, id))
        {
        }

        private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? options, Input<string>? id)
        {
            var defaultOptions = new CustomResourceOptions
            {
                Version = Utilities.Version,
                PluginDownloadURL = "https://github.com/regrau/pulumi-yandex/releases",
                AdditionalSecretOutputs =
                {
                    "password",
                },
            };
            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 MdbPostgresqlUser 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 MdbPostgresqlUser Get(string name, Input<string> id, MdbPostgresqlUserState? state = null, CustomResourceOptions? options = null)
        {
            return new MdbPostgresqlUser(name, id, state, options);
        }
    }

    public sealed class MdbPostgresqlUserArgs : global::Pulumi.ResourceArgs
    {
        [Input("clusterId", required: true)]
        public Input<string> ClusterId { get; set; } = null!;

        /// <summary>
        /// The maximum number of connections per user. (Default 50)
        /// </summary>
        [Input("connLimit")]
        public Input<int>? ConnLimit { get; set; }

        [Input("grants")]
        private InputList<string>? _grants;

        /// <summary>
        /// List of the user's grants.
        /// </summary>
        public InputList<string> Grants
        {
            get => _grants ?? (_grants = new InputList<string>());
            set => _grants = value;
        }

        /// <summary>
        /// User's ability to login.
        /// </summary>
        [Input("login")]
        public Input<bool>? Login { get; set; }

        /// <summary>
        /// The name of the user.
        /// </summary>
        [Input("name")]
        public Input<string>? Name { get; set; }

        [Input("password", required: true)]
        private Input<string>? _password;

        /// <summary>
        /// The password of the user.
        /// </summary>
        public Input<string>? Password
        {
            get => _password;
            set
            {
                var emptySecret = Output.CreateSecret(0);
                _password = Output.Tuple<Input<string>?, int>(value, emptySecret).Apply(t => t.Item1);
            }
        }

        [Input("permissions")]
        private InputList<Inputs.MdbPostgresqlUserPermissionArgs>? _permissions;

        /// <summary>
        /// Set of permissions granted to the user. The structure is documented below.
        /// </summary>
        public InputList<Inputs.MdbPostgresqlUserPermissionArgs> Permissions
        {
            get => _permissions ?? (_permissions = new InputList<Inputs.MdbPostgresqlUserPermissionArgs>());
            set => _permissions = value;
        }

        [Input("settings")]
        private InputMap<string>? _settings;

        /// <summary>
        /// Map of user settings. List of settings is documented below.
        /// </summary>
        public InputMap<string> Settings
        {
            get => _settings ?? (_settings = new InputMap<string>());
            set => _settings = value;
        }

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

    public sealed class MdbPostgresqlUserState : global::Pulumi.ResourceArgs
    {
        [Input("clusterId")]
        public Input<string>? ClusterId { get; set; }

        /// <summary>
        /// The maximum number of connections per user. (Default 50)
        /// </summary>
        [Input("connLimit")]
        public Input<int>? ConnLimit { get; set; }

        [Input("grants")]
        private InputList<string>? _grants;

        /// <summary>
        /// List of the user's grants.
        /// </summary>
        public InputList<string> Grants
        {
            get => _grants ?? (_grants = new InputList<string>());
            set => _grants = value;
        }

        /// <summary>
        /// User's ability to login.
        /// </summary>
        [Input("login")]
        public Input<bool>? Login { get; set; }

        /// <summary>
        /// The name of the user.
        /// </summary>
        [Input("name")]
        public Input<string>? Name { get; set; }

        [Input("password")]
        private Input<string>? _password;

        /// <summary>
        /// The password of the user.
        /// </summary>
        public Input<string>? Password
        {
            get => _password;
            set
            {
                var emptySecret = Output.CreateSecret(0);
                _password = Output.Tuple<Input<string>?, int>(value, emptySecret).Apply(t => t.Item1);
            }
        }

        [Input("permissions")]
        private InputList<Inputs.MdbPostgresqlUserPermissionGetArgs>? _permissions;

        /// <summary>
        /// Set of permissions granted to the user. The structure is documented below.
        /// </summary>
        public InputList<Inputs.MdbPostgresqlUserPermissionGetArgs> Permissions
        {
            get => _permissions ?? (_permissions = new InputList<Inputs.MdbPostgresqlUserPermissionGetArgs>());
            set => _permissions = value;
        }

        [Input("settings")]
        private InputMap<string>? _settings;

        /// <summary>
        /// Map of user settings. List of settings is documented below.
        /// </summary>
        public InputMap<string> Settings
        {
            get => _settings ?? (_settings = new InputMap<string>());
            set => _settings = value;
        }

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