// FilterValidConsumerGroupIDs returns the list of consumer group IDs from the API
FilterValidConsumerGroupIDs returns the list of consumer group IDs from the API
// FilterValidConsumerGroupIDs returns the list of consumer group IDs from the API
func FilterValidConsumerGroupIDs(f *factory.Factory, toComplete string) (validIDs []string, directive cobra.ShellCompDirective) {
	validIDs = []string{}
	directive = cobra.ShellCompDirectiveNoSpace
	svcContext, err := f.ServiceContext.Load()
	if err != nil {
		return validIDs, directive
	}
	currCtx, err := contextutil.GetCurrentContext(svcContext, f.Localizer)
	if err != nil {
		return validIDs, directive
	}
	instanceID := currCtx.KafkaID
	if instanceID == "" {
		return validIDs, directive
	}
	conn, err := f.Connection(connection.DefaultConfigRequireMasAuth)
	if err != nil {
		return validIDs, directive
	}
	api, _, err := conn.API().KafkaAdmin(instanceID)
	if err != nil {
		return validIDs, directive
	}
	req := api.GroupsApi.GetConsumerGroups(f.Context)
	if toComplete != "" {
		req = req.GroupIdFilter(toComplete)
	}
	cgRes, httpRes, err := req.Execute()
	if httpRes != nil {
		defer func() {
			_ = httpRes.Body.Close()
		}()
	}
	if err != nil {
		return validIDs, directive
	}
	items := cgRes.GetItems()
	for _, cg := range items {
		validIDs = append(validIDs, cg.GetGroupId())
	}
	return validIDs, directive
}
func FilterValidConsumerGroupIDs ( f * factory . Factory , toComplete string ) ( validIDs [ ] string , directive cobra . ShellCompDirective ) { validIDs = [ ] string { } directive = cobra . ShellCompDirectiveNoSpace svcContext , err := f . ServiceContext . Load ( ) if err != nil { return validIDs , directive } currCtx , err := contextutil . GetCurrentContext ( svcContext , f . Localizer ) if err != nil { return validIDs , directive } instanceID := currCtx . KafkaID if instanceID == " " { return validIDs , directive } conn , err := f . Connection ( connection . DefaultConfigRequireMasAuth ) if err != nil { return validIDs , directive } api , _ , err := conn . API ( ) . KafkaAdmin ( instanceID ) if err != nil { return validIDs , directive } req := api . GroupsApi . GetConsumerGroups ( f . Context ) if toComplete != " " { req = req . GroupIdFilter ( toComplete ) } cgRes , httpRes , err := req . Execute ( ) if httpRes != nil { defer func ( ) { _ = httpRes . Body . Close ( ) } ( ) } if err != nil { return validIDs , directive } items := cgRes . GetItems ( ) for _ , cg := range items { validIDs = append ( validIDs , cg . GetGroupId ( ) ) } return validIDs , directive }
FilterValidConsumerGroupIDs returns the list of consumer group IDs from the API
FilterValidConsumerGroupIDs returns the list of consumer group IDs from the API