// *** 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
{
    public static class GetAccounts
    {
        /// <summary>
        /// The `alicloud.polardb.getAccounts` data source provides a collection of PolarDB cluster database account available in Alibaba Cloud account.
        /// Filters support regular expression for the account name, searches by clusterId.
        /// 
        /// &gt; **NOTE:** Available in v1.70.0+.
        /// 
        /// {{% examples %}}
        /// ## Example Usage
        /// {{% example %}}
        /// 
        /// ```csharp
        /// using System.Collections.Generic;
        /// using Pulumi;
        /// using AliCloud = Pulumi.AliCloud;
        /// 
        /// return await Deployment.RunAsync(() =&gt; 
        /// {
        ///     var polardbClustersDs = AliCloud.PolarDB.GetClusters.Invoke(new()
        ///     {
        ///         DescriptionRegex = "pc-\\w+",
        ///         Status = "Running",
        ///     });
        /// 
        ///     var @default = AliCloud.PolarDB.GetAccounts.Invoke(new()
        ///     {
        ///         DbClusterId = polardbClustersDs.Apply(getClustersResult =&gt; getClustersResult.Clusters[0]?.Id),
        ///     });
        /// 
        ///     return new Dictionary&lt;string, object?&gt;
        ///     {
        ///         ["account"] = @default.Apply(getAccountsResult =&gt; getAccountsResult).Apply(@default =&gt; @default.Apply(getAccountsResult =&gt; getAccountsResult.Accounts[0]?.AccountName)),
        ///     };
        /// });
        /// ```
        /// {{% /example %}}
        /// {{% /examples %}}
        /// </summary>
        public static Task<GetAccountsResult> InvokeAsync(GetAccountsArgs args, InvokeOptions? options = null)
            => Pulumi.Deployment.Instance.InvokeAsync<GetAccountsResult>("alicloud:polardb/getAccounts:getAccounts", args ?? new GetAccountsArgs(), options.WithDefaults());

        /// <summary>
        /// The `alicloud.polardb.getAccounts` data source provides a collection of PolarDB cluster database account available in Alibaba Cloud account.
        /// Filters support regular expression for the account name, searches by clusterId.
        /// 
        /// &gt; **NOTE:** Available in v1.70.0+.
        /// 
        /// {{% examples %}}
        /// ## Example Usage
        /// {{% example %}}
        /// 
        /// ```csharp
        /// using System.Collections.Generic;
        /// using Pulumi;
        /// using AliCloud = Pulumi.AliCloud;
        /// 
        /// return await Deployment.RunAsync(() =&gt; 
        /// {
        ///     var polardbClustersDs = AliCloud.PolarDB.GetClusters.Invoke(new()
        ///     {
        ///         DescriptionRegex = "pc-\\w+",
        ///         Status = "Running",
        ///     });
        /// 
        ///     var @default = AliCloud.PolarDB.GetAccounts.Invoke(new()
        ///     {
        ///         DbClusterId = polardbClustersDs.Apply(getClustersResult =&gt; getClustersResult.Clusters[0]?.Id),
        ///     });
        /// 
        ///     return new Dictionary&lt;string, object?&gt;
        ///     {
        ///         ["account"] = @default.Apply(getAccountsResult =&gt; getAccountsResult).Apply(@default =&gt; @default.Apply(getAccountsResult =&gt; getAccountsResult.Accounts[0]?.AccountName)),
        ///     };
        /// });
        /// ```
        /// {{% /example %}}
        /// {{% /examples %}}
        /// </summary>
        public static Output<GetAccountsResult> Invoke(GetAccountsInvokeArgs args, InvokeOptions? options = null)
            => Pulumi.Deployment.Instance.Invoke<GetAccountsResult>("alicloud:polardb/getAccounts:getAccounts", args ?? new GetAccountsInvokeArgs(), options.WithDefaults());
    }


    public sealed class GetAccountsArgs : global::Pulumi.InvokeArgs
    {
        /// <summary>
        /// The polarDB cluster ID.
        /// </summary>
        [Input("dbClusterId", required: true)]
        public string DbClusterId { get; set; } = null!;

        /// <summary>
        /// A regex string to filter results by account name.
        /// </summary>
        [Input("nameRegex")]
        public string? NameRegex { get; set; }

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

    public sealed class GetAccountsInvokeArgs : global::Pulumi.InvokeArgs
    {
        /// <summary>
        /// The polarDB cluster ID.
        /// </summary>
        [Input("dbClusterId", required: true)]
        public Input<string> DbClusterId { get; set; } = null!;

        /// <summary>
        /// A regex string to filter results by account name.
        /// </summary>
        [Input("nameRegex")]
        public Input<string>? NameRegex { get; set; }

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


    [OutputType]
    public sealed class GetAccountsResult
    {
        /// <summary>
        /// A list of PolarDB cluster accounts. Each element contains the following attributes:
        /// </summary>
        public readonly ImmutableArray<Outputs.GetAccountsAccountResult> Accounts;
        public readonly string DbClusterId;
        /// <summary>
        /// The provider-assigned unique ID for this managed resource.
        /// </summary>
        public readonly string Id;
        public readonly string? NameRegex;
        /// <summary>
        /// Account name of the cluster.
        /// </summary>
        public readonly ImmutableArray<string> Names;

        [OutputConstructor]
        private GetAccountsResult(
            ImmutableArray<Outputs.GetAccountsAccountResult> accounts,

            string dbClusterId,

            string id,

            string? nameRegex,

            ImmutableArray<string> names)
        {
            Accounts = accounts;
            DbClusterId = dbClusterId;
            Id = id;
            NameRegex = nameRegex;
            Names = names;
        }
    }
}
