// *** 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.RocketMQ
{
    public static class GetGroups
    {
        /// <summary>
        /// This data source provides a list of ONS Groups in an Alibaba Cloud account according to the specified filters.
        /// 
        /// &gt; **NOTE:** Available in 1.53.0+
        /// 
        /// {{% examples %}}
        /// ## Example Usage
        /// {{% example %}}
        /// 
        /// ```csharp
        /// using System.Collections.Generic;
        /// using Pulumi;
        /// using AliCloud = Pulumi.AliCloud;
        /// 
        /// return await Deployment.RunAsync(() =&gt; 
        /// {
        ///     var config = new Config();
        ///     var name = config.Get("name") ?? "onsInstanceName";
        ///     var groupName = config.Get("groupName") ?? "GID-onsGroupDatasourceName";
        ///     var defaultInstance = new AliCloud.RocketMQ.Instance("defaultInstance", new()
        ///     {
        ///         InstanceName = name,
        ///         Remark = "default_ons_instance_remark",
        ///     });
        /// 
        ///     var defaultGroup = new AliCloud.RocketMQ.Group("defaultGroup", new()
        ///     {
        ///         GroupName = groupName,
        ///         InstanceId = defaultInstance.Id,
        ///         Remark = "dafault_ons_group_remark",
        ///     });
        /// 
        ///     var groupsDs = AliCloud.RocketMQ.GetGroups.Invoke(new()
        ///     {
        ///         InstanceId = defaultGroup.InstanceId,
        ///         NameRegex = @var.Group_id,
        ///         OutputFile = "groups.txt",
        ///     });
        /// 
        ///     return new Dictionary&lt;string, object?&gt;
        ///     {
        ///         ["firstGroupName"] = groupsDs.Apply(getGroupsResult =&gt; getGroupsResult.Groups[0]?.GroupName),
        ///     };
        /// });
        /// ```
        /// {{% /example %}}
        /// {{% /examples %}}
        /// </summary>
        public static Task<GetGroupsResult> InvokeAsync(GetGroupsArgs args, InvokeOptions? options = null)
            => Pulumi.Deployment.Instance.InvokeAsync<GetGroupsResult>("alicloud:rocketmq/getGroups:getGroups", args ?? new GetGroupsArgs(), options.WithDefaults());

        /// <summary>
        /// This data source provides a list of ONS Groups in an Alibaba Cloud account according to the specified filters.
        /// 
        /// &gt; **NOTE:** Available in 1.53.0+
        /// 
        /// {{% examples %}}
        /// ## Example Usage
        /// {{% example %}}
        /// 
        /// ```csharp
        /// using System.Collections.Generic;
        /// using Pulumi;
        /// using AliCloud = Pulumi.AliCloud;
        /// 
        /// return await Deployment.RunAsync(() =&gt; 
        /// {
        ///     var config = new Config();
        ///     var name = config.Get("name") ?? "onsInstanceName";
        ///     var groupName = config.Get("groupName") ?? "GID-onsGroupDatasourceName";
        ///     var defaultInstance = new AliCloud.RocketMQ.Instance("defaultInstance", new()
        ///     {
        ///         InstanceName = name,
        ///         Remark = "default_ons_instance_remark",
        ///     });
        /// 
        ///     var defaultGroup = new AliCloud.RocketMQ.Group("defaultGroup", new()
        ///     {
        ///         GroupName = groupName,
        ///         InstanceId = defaultInstance.Id,
        ///         Remark = "dafault_ons_group_remark",
        ///     });
        /// 
        ///     var groupsDs = AliCloud.RocketMQ.GetGroups.Invoke(new()
        ///     {
        ///         InstanceId = defaultGroup.InstanceId,
        ///         NameRegex = @var.Group_id,
        ///         OutputFile = "groups.txt",
        ///     });
        /// 
        ///     return new Dictionary&lt;string, object?&gt;
        ///     {
        ///         ["firstGroupName"] = groupsDs.Apply(getGroupsResult =&gt; getGroupsResult.Groups[0]?.GroupName),
        ///     };
        /// });
        /// ```
        /// {{% /example %}}
        /// {{% /examples %}}
        /// </summary>
        public static Output<GetGroupsResult> Invoke(GetGroupsInvokeArgs args, InvokeOptions? options = null)
            => Pulumi.Deployment.Instance.Invoke<GetGroupsResult>("alicloud:rocketmq/getGroups:getGroups", args ?? new GetGroupsInvokeArgs(), options.WithDefaults());
    }


    public sealed class GetGroupsArgs : global::Pulumi.InvokeArgs
    {
        /// <summary>
        /// A regex string to filter results by the group name.
        /// </summary>
        [Input("groupIdRegex")]
        public string? GroupIdRegex { get; set; }

        /// <summary>
        /// Specify the protocol applicable to the created Group ID. Valid values: `tcp`, `http`. Default to `tcp`.
        /// </summary>
        [Input("groupType")]
        public string? GroupType { get; set; }

        [Input("ids")]
        private List<string>? _ids;

        /// <summary>
        /// A list of group names.
        /// </summary>
        public List<string> Ids
        {
            get => _ids ?? (_ids = new List<string>());
            set => _ids = value;
        }

        /// <summary>
        /// ID of the ONS Instance that owns the groups.
        /// </summary>
        [Input("instanceId", required: true)]
        public string InstanceId { get; set; } = null!;

        [Input("nameRegex")]
        public string? NameRegex { get; set; }

        [Input("outputFile")]
        public string? OutputFile { get; set; }

        [Input("tags")]
        private Dictionary<string, object>? _tags;

        /// <summary>
        /// A map of tags assigned to the Ons instance.
        /// </summary>
        public Dictionary<string, object> Tags
        {
            get => _tags ?? (_tags = new Dictionary<string, object>());
            set => _tags = value;
        }

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

    public sealed class GetGroupsInvokeArgs : global::Pulumi.InvokeArgs
    {
        /// <summary>
        /// A regex string to filter results by the group name.
        /// </summary>
        [Input("groupIdRegex")]
        public Input<string>? GroupIdRegex { get; set; }

        /// <summary>
        /// Specify the protocol applicable to the created Group ID. Valid values: `tcp`, `http`. Default to `tcp`.
        /// </summary>
        [Input("groupType")]
        public Input<string>? GroupType { get; set; }

        [Input("ids")]
        private InputList<string>? _ids;

        /// <summary>
        /// A list of group names.
        /// </summary>
        public InputList<string> Ids
        {
            get => _ids ?? (_ids = new InputList<string>());
            set => _ids = value;
        }

        /// <summary>
        /// ID of the ONS Instance that owns the groups.
        /// </summary>
        [Input("instanceId", required: true)]
        public Input<string> InstanceId { get; set; } = null!;

        [Input("nameRegex")]
        public Input<string>? NameRegex { get; set; }

        [Input("outputFile")]
        public Input<string>? OutputFile { get; set; }

        [Input("tags")]
        private InputMap<object>? _tags;

        /// <summary>
        /// A map of tags assigned to the Ons instance.
        /// </summary>
        public InputMap<object> Tags
        {
            get => _tags ?? (_tags = new InputMap<object>());
            set => _tags = value;
        }

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


    [OutputType]
    public sealed class GetGroupsResult
    {
        public readonly string? GroupIdRegex;
        /// <summary>
        /// Specify the protocol applicable to the created Group ID.
        /// </summary>
        public readonly string? GroupType;
        /// <summary>
        /// A list of groups. Each element contains the following attributes:
        /// </summary>
        public readonly ImmutableArray<Outputs.GetGroupsGroupResult> Groups;
        /// <summary>
        /// The provider-assigned unique ID for this managed resource.
        /// </summary>
        public readonly string Id;
        /// <summary>
        /// A list of group names.
        /// </summary>
        public readonly ImmutableArray<string> Ids;
        public readonly string InstanceId;
        public readonly string? NameRegex;
        public readonly ImmutableArray<string> Names;
        public readonly string? OutputFile;
        /// <summary>
        /// A map of tags assigned to the Ons group.
        /// </summary>
        public readonly ImmutableDictionary<string, object>? Tags;

        [OutputConstructor]
        private GetGroupsResult(
            string? groupIdRegex,

            string? groupType,

            ImmutableArray<Outputs.GetGroupsGroupResult> groups,

            string id,

            ImmutableArray<string> ids,

            string instanceId,

            string? nameRegex,

            ImmutableArray<string> names,

            string? outputFile,

            ImmutableDictionary<string, object>? tags)
        {
            GroupIdRegex = groupIdRegex;
            GroupType = groupType;
            Groups = groups;
            Id = id;
            Ids = ids;
            InstanceId = instanceId;
            NameRegex = nameRegex;
            Names = names;
            OutputFile = outputFile;
            Tags = tags;
        }
    }
}
