<filename>sdk/dotnet/PolarDB/GetDatabases.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.AliCloud.PolarDB
{
    public static class GetDatabases
    {
        /// <summary>
        /// The `alicloud.polardb.getDatabases` data source provides a collection of PolarDB cluster database available in Alibaba Cloud account.
        /// Filters support regular expression for the database 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.GetDatabases.Invoke(new()
        ///     {
        ///         DbClusterId = polardbClustersDs.Apply(getClustersResult =&gt; getClustersResult.Clusters[0]?.Id),
        ///     });
        /// 
        ///     return new Dictionary&lt;string, object?&gt;
        ///     {
        ///         ["database"] = @default.Apply(getDatabasesResult =&gt; getDatabasesResult).Apply(@default =&gt; @default.Apply(getDatabasesResult =&gt; getDatabasesResult.Databases[0]?.DbName)),
        ///     };
        /// });
        /// ```
        /// {{% /example %}}
        /// {{% /examples %}}
        /// </summary>
        public static Task<GetDatabasesResult> InvokeAsync(GetDatabasesArgs args, InvokeOptions? options = null)
            => Pulumi.Deployment.Instance.InvokeAsync<GetDatabasesResult>("alicloud:polardb/getDatabases:getDatabases", args ?? new GetDatabasesArgs(), options.WithDefaults());

        /// <summary>
        /// The `alicloud.polardb.getDatabases` data source provides a collection of PolarDB cluster database available in Alibaba Cloud account.
        /// Filters support regular expression for the database 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.GetDatabases.Invoke(new()
        ///     {
        ///         DbClusterId = polardbClustersDs.Apply(getClustersResult =&gt; getClustersResult.Clusters[0]?.Id),
        ///     });
        /// 
        ///     return new Dictionary&lt;string, object?&gt;
        ///     {
        ///         ["database"] = @default.Apply(getDatabasesResult =&gt; getDatabasesResult).Apply(@default =&gt; @default.Apply(getDatabasesResult =&gt; getDatabasesResult.Databases[0]?.DbName)),
        ///     };
        /// });
        /// ```
        /// {{% /example %}}
        /// {{% /examples %}}
        /// </summary>
        public static Output<GetDatabasesResult> Invoke(GetDatabasesInvokeArgs args, InvokeOptions? options = null)
            => Pulumi.Deployment.Instance.Invoke<GetDatabasesResult>("alicloud:polardb/getDatabases:getDatabases", args ?? new GetDatabasesInvokeArgs(), options.WithDefaults());
    }


    public sealed class GetDatabasesArgs : 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 database name.
        /// </summary>
        [Input("nameRegex")]
        public string? NameRegex { get; set; }

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

    public sealed class GetDatabasesInvokeArgs : 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 database name.
        /// </summary>
        [Input("nameRegex")]
        public Input<string>? NameRegex { get; set; }

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


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

        [OutputConstructor]
        private GetDatabasesResult(
            ImmutableArray<Outputs.GetDatabasesDatabaseResult> databases,

            string dbClusterId,

            string id,

            string? nameRegex,

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