// *** 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.AliCloud.PolarDB
{
    /// <summary>
    /// Provides a PolarDB account privilege resource and used to grant several database some access privilege. A database can be granted by multiple account.
    /// 
    /// &gt; **NOTE:** Available in v1.67.0+.
    /// 
    /// ## Example Usage
    /// 
    /// ```csharp
    /// using System.Collections.Generic;
    /// using Pulumi;
    /// using AliCloud = Pulumi.AliCloud;
    /// 
    /// return await Deployment.RunAsync(() =&gt; 
    /// {
    ///     var config = new Config();
    ///     var creation = config.Get("creation") ?? "PolarDB";
    ///     var name = config.Get("name") ?? "dbaccountprivilegebasic";
    ///     var defaultZones = AliCloud.GetZones.Invoke(new()
    ///     {
    ///         AvailableResourceCreation = creation,
    ///     });
    /// 
    ///     var defaultNetwork = new AliCloud.Vpc.Network("defaultNetwork", new()
    ///     {
    ///         CidrBlock = "172.16.0.0/16",
    ///     });
    /// 
    ///     var defaultSwitch = new AliCloud.Vpc.Switch("defaultSwitch", new()
    ///     {
    ///         VpcId = defaultNetwork.Id,
    ///         CidrBlock = "172.16.0.0/24",
    ///         ZoneId = defaultZones.Apply(getZonesResult =&gt; getZonesResult.Zones[0]?.Id),
    ///     });
    /// 
    ///     var cluster = new AliCloud.PolarDB.Cluster("cluster", new()
    ///     {
    ///         DbType = "MySQL",
    ///         DbVersion = "8.0",
    ///         PayType = "PostPaid",
    ///         DbNodeClass = "polar.mysql.x4.large",
    ///         VswitchId = defaultSwitch.Id,
    ///         Description = name,
    ///     });
    /// 
    ///     var db = new AliCloud.PolarDB.Database("db", new()
    ///     {
    ///         DbClusterId = cluster.Id,
    ///         DbName = "tftestdatabase",
    ///     });
    /// 
    ///     var account = new AliCloud.PolarDB.Account("account", new()
    ///     {
    ///         DbClusterId = cluster.Id,
    ///         AccountName = "tftestnormal",
    ///         AccountPassword = "Test12345",
    ///         AccountDescription = name,
    ///     });
    /// 
    ///     var privilege = new AliCloud.PolarDB.AccountPrivilege("privilege", new()
    ///     {
    ///         DbClusterId = cluster.Id,
    ///         AccountName = account.AccountName,
    ///         Privilege = "ReadOnly",
    ///         DbNames = new[]
    ///         {
    ///             db.DbName,
    ///         },
    ///     });
    /// 
    /// });
    /// ```
    /// 
    /// ## Import
    /// 
    /// PolarDB account privilege can be imported using the id, e.g.
    /// 
    /// ```sh
    ///  $ pulumi import alicloud:polardb/accountPrivilege:AccountPrivilege example "pc-12345:tf_account:ReadOnly"
    /// ```
    /// </summary>
    [AliCloudResourceType("alicloud:polardb/accountPrivilege:AccountPrivilege")]
    public partial class AccountPrivilege : global::Pulumi.CustomResource
    {
        /// <summary>
        /// A specified account name.
        /// </summary>
        [Output("accountName")]
        public Output<string> AccountName { get; private set; } = null!;

        /// <summary>
        /// The privilege of one account access database. Valid values: ["ReadOnly", "ReadWrite"], ["DMLOnly", "DDLOnly"] added since version v1.101.0. Default to "ReadOnly".
        /// </summary>
        [Output("accountPrivilege")]
        public Output<string?> Privilege { get; private set; } = null!;

        /// <summary>
        /// The Id of cluster in which account belongs.
        /// </summary>
        [Output("dbClusterId")]
        public Output<string> DbClusterId { get; private set; } = null!;

        /// <summary>
        /// List of specified database name.
        /// </summary>
        [Output("dbNames")]
        public Output<ImmutableArray<string>> DbNames { get; private set; } = null!;


        /// <summary>
        /// Create a AccountPrivilege 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 AccountPrivilege(string name, AccountPrivilegeArgs args, CustomResourceOptions? options = null)
            : base("alicloud:polardb/accountPrivilege:AccountPrivilege", name, args ?? new AccountPrivilegeArgs(), MakeResourceOptions(options, ""))
        {
        }

        private AccountPrivilege(string name, Input<string> id, AccountPrivilegeState? state = null, CustomResourceOptions? options = null)
            : base("alicloud:polardb/accountPrivilege:AccountPrivilege", 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/rhysmdnz/pulumi-alicloud",
            };
            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 AccountPrivilege 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 AccountPrivilege Get(string name, Input<string> id, AccountPrivilegeState? state = null, CustomResourceOptions? options = null)
        {
            return new AccountPrivilege(name, id, state, options);
        }
    }

    public sealed class AccountPrivilegeArgs : global::Pulumi.ResourceArgs
    {
        /// <summary>
        /// A specified account name.
        /// </summary>
        [Input("accountName", required: true)]
        public Input<string> AccountName { get; set; } = null!;

        /// <summary>
        /// The privilege of one account access database. Valid values: ["ReadOnly", "ReadWrite"], ["DMLOnly", "DDLOnly"] added since version v1.101.0. Default to "ReadOnly".
        /// </summary>
        [Input("accountPrivilege")]
        public Input<string>? Privilege { get; set; }

        /// <summary>
        /// The Id of cluster in which account belongs.
        /// </summary>
        [Input("dbClusterId", required: true)]
        public Input<string> DbClusterId { get; set; } = null!;

        [Input("dbNames", required: true)]
        private InputList<string>? _dbNames;

        /// <summary>
        /// List of specified database name.
        /// </summary>
        public InputList<string> DbNames
        {
            get => _dbNames ?? (_dbNames = new InputList<string>());
            set => _dbNames = value;
        }

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

    public sealed class AccountPrivilegeState : global::Pulumi.ResourceArgs
    {
        /// <summary>
        /// A specified account name.
        /// </summary>
        [Input("accountName")]
        public Input<string>? AccountName { get; set; }

        /// <summary>
        /// The privilege of one account access database. Valid values: ["ReadOnly", "ReadWrite"], ["DMLOnly", "DDLOnly"] added since version v1.101.0. Default to "ReadOnly".
        /// </summary>
        [Input("accountPrivilege")]
        public Input<string>? Privilege { get; set; }

        /// <summary>
        /// The Id of cluster in which account belongs.
        /// </summary>
        [Input("dbClusterId")]
        public Input<string>? DbClusterId { get; set; }

        [Input("dbNames")]
        private InputList<string>? _dbNames;

        /// <summary>
        /// List of specified database name.
        /// </summary>
        public InputList<string> DbNames
        {
            get => _dbNames ?? (_dbNames = new InputList<string>());
            set => _dbNames = value;
        }

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