// AllServiceGroups returns all the ServiceGroups that aren't in the excludes set and the set of covered NodeIDs
11463
func AllServiceGroups(g osgraph.Graph, excludeNodeIDs IntSet) ([]ServiceGroup, IntSet) {
	covered := IntSet{}
	services := []ServiceGroup{}

	for _, uncastNode := range g.NodesByKind(kubegraph.ServiceNodeKind) {
		if excludeNodeIDs.Has(uncastNode.ID()) {
			continue
		}

		service, covers := NewServiceGroup(g, uncastNode.(*kubegraph.ServiceNode))
		covered.Insert(covers.List()...)
		services = append(services, service)
	}

	sort.Sort(ServiceGroupByObjectMeta(services))
	return services, covered
}
245937
func (h *Health) ServiceNodes(args *structs.ServiceSpecificRequest, reply *structs.IndexedCheckServiceNodes) error {
	if done, err := h.srv.forward("Health.ServiceNodes", args, args, reply); done {
		return err
	}

	// Verify the arguments
	if args.ServiceName == "" {
		return fmt.Errorf("Must provide service name")
	}

	// Determine the function we'll call
	var f func(memdb.WatchSet, *state.Store, *structs.ServiceSpecificRequest) (uint64, structs.CheckServiceNodes, error)
	switch {
	case args.Connect:
		f = h.serviceNodesConnect
	case args.TagFilter:
		f = h.serviceNodesTagFilter
	default:
		f = h.serviceNodesDefault
	}

	// If we're doing a connect query, we need read access to the service
	// we're trying to find proxies for, so check that.
	if args.Connect {
		// Fetch the ACL token, if any.
		rule, err := h.srv.ResolveToken(args.Token)
		if err != nil {
			return err
		}

		if rule != nil && !rule.ServiceRead(args.ServiceName) {
			// Just return nil, which will return an empty response (tested)
			return nil
		}
	}

	filter, err := bexpr.CreateFilter(args.Filter, nil, reply.Nodes)
	if err != nil {
		return err
	}

	err = h.srv.blockingQuery(
		&args.QueryOptions,
		&reply.QueryMeta,
		func(ws memdb.WatchSet, state *state.Store) error {
			index, nodes, err := f(ws, state, args)
			if err != nil {
				return err
			}

			reply.Index, reply.Nodes = index, nodes
			if len(args.NodeMetaFilters) > 0 {
				reply.Nodes = nodeMetaFilter(args.NodeMetaFilters, reply.Nodes)
			}

			if err := h.srv.filterACL(args.Token, reply); err != nil {
				return err
			}

			raw, err := filter.Execute(reply.Nodes)
			if err != nil {
				return err
			}
			reply.Nodes = raw.(structs.CheckServiceNodes)

			return h.srv.sortNodesByDistanceFrom(args.Source, reply.Nodes)
		})

	// Provide some metrics
	if err == nil {
		// For metrics, we separate Connect-based lookups from non-Connect
		key := "service"
		if args.Connect {
			key = "connect"
		}

		metrics.IncrCounterWithLabels([]string{"health", key, "query"}, 1,
			[]metrics.Label{{Name: "service", Value: args.ServiceName}})
		// DEPRECATED (singular-service-tag) - remove this when backwards RPC compat
		// with 1.2.x is not required.
		if args.ServiceTag != "" {
			metrics.IncrCounterWithLabels([]string{"health", key, "query-tag"}, 1,
				[]metrics.Label{{Name: "service", Value: args.ServiceName}, {Name: "tag", Value: args.ServiceTag}})
		}
		if len(args.ServiceTags) > 0 {
			// Sort tags so that the metric is the same even if the request
			// tags are in a different order
			sort.Strings(args.ServiceTags)

			labels := []metrics.Label{{Name: "service", Value: args.ServiceName}}
			for _, tag := range args.ServiceTags {
				labels = append(labels, metrics.Label{Name: "tag", Value: tag})
			}
			metrics.IncrCounterWithLabels([]string{"health", key, "query-tags"}, 1, labels)
		}
		if len(reply.Nodes) == 0 {
			metrics.IncrCounterWithLabels([]string{"health", key, "not-found"}, 1,
				[]metrics.Label{{Name: "service", Value: args.ServiceName}})
		}
	}
	return err
}
504980
func (p *PUPolicy) ExposedServices() ApplicationServicesList {
	p.Lock()
	defer p.Unlock()

	return p.exposedServices
}
1100549
func (d *CachedDiscoveryClient) ServerGroupsAndResources() ([]*metav1.APIGroup, []*metav1.APIResourceList, error) {
	return discovery.ServerGroupsAndResources(d)
}
1240126
func (res *GroupsListAPIResponse) Groups() ([]*Group, error) {
	var groups []*Group
	err := json.Unmarshal(res.RawGroups, &groups)
	if err != nil {
		return nil, err
	}
	return groups, nil
}
923683
func (s *GetAppOutput) SetServerGroups(v []*ServerGroup) *GetAppOutput {
	s.ServerGroups = v
	return s
}
1083015
func (c *legacyNovaFirewaller) DeleteAllModelGroups(ctx context.ProviderCallContext) error {
	return deleteSecurityGroupsMatchingName(ctx, c.deleteSecurityGroups, c.jujuGroupRegexp())
}
921703
func listServices(scmgr WinServiceManager, userServices []string) ([]string, error) {
	if len(userServices) != 0 {
		return userServices, nil
	}

	names, err := scmgr.ListServices()
	if err != nil {
		return nil, fmt.Errorf("Could not list services: %s", err)
	}
	return names, nil
}
939961
func (s *Ec2InstanceAttributes) SetServiceAccessSecurityGroup(v string) *Ec2InstanceAttributes {
	s.ServiceAccessSecurityGroup = &v
	return s
}
918192
func (s *Server) RemoveAllServices() error {
	s.Lock()
	defer s.Unlock()
	s.svcs = defaultServices(s.name)
	s.db = att.NewDB(s.svcs, uint16(1)) // ble attrs start at 1
	return nil
}
558869
func (c *rackspaceFirewaller) DeleteAllControllerGroups(ctx context.ProviderCallContext, controllerUUID string) error {
	return nil
}
204488
func (c *kregistry) ListServices() ([]*registry.Service, error) {
	pods, err := c.client.ListPods(podSelector)
	if err != nil {
		return nil, err
	}

	// svcs mapped by name
	svcs := make(map[string]bool)

	for _, pod := range pods.Items {
		if pod.Status.Phase != podRunning {
			continue
		}
		for k, v := range pod.Metadata.Annotations {
			if !strings.HasPrefix(k, annotationServiceKeyPrefix) {
				continue
			}

			// we have to unmarshal the annotation itself since the
			// key is encoded to match the regex restriction.
			var svc registry.Service
			if err := json.Unmarshal([]byte(*v), &svc); err != nil {
				continue
			}
			svcs[svc.Name] = true
		}
	}

	var list []*registry.Service
	for val := range svcs {
		list = append(list, &registry.Service{Name: val})
	}
	return list, nil
}
835482
func (s *DelegatingAuthorizationOptions) WithAlwaysAllowGroups(groups ...string) *DelegatingAuthorizationOptions {
	s.AlwaysAllowGroups = append(s.AlwaysAllowGroups, groups...)
	return s
}
1345636
func (s *NodesStatsService) Groups(groups bool) *NodesStatsService {
	s.groups = &groups
	return s
}
443582
func (f *Facade) GetAggregateServices(ctx datastore.Context, since time.Time, serviceIDs []string) ([]service.AggregateService, error) {
	defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.GetAggregateServices"))
	logger := plog.WithField("serviceids", strings.Join(serviceIDs, ","))

	// Create an instance map to map instances to their memory usage.  This is
	// so that we only have to make one call to query service to get metrics
	// for all the instances.
	instanceMap := make(map[string]*service.Usage)

	// Set up an array containing all the metrics to collect
	var metricsreq []metrics.ServiceInstance

	// Results are for saving the metric data that will be returned to the
	// caller.
	results := make([]service.AggregateService, len(serviceIDs))

	for i, serviceID := range serviceIDs {
		svclog := logger.WithField("serviceid", serviceID)

		svc, err := f.serviceStore.GetServiceHealth(ctx, serviceID)
		if datastore.IsErrNoSuchEntity(err) {

			// If the service is not found, set the NotFound boolean to true
			// and continue
			results[i] = service.AggregateService{
				ServiceID: serviceID,
				NotFound:  true,
			}
			svclog.Debug("Service not found")
			continue
		} else if err != nil {
			svclog.WithError(err).Debug("Could not retrieve service")
			return nil, err
		}

		// Get all the state ids running on that service
		stateIDs, err := f.zzk.GetServiceStateIDs(svc.PoolID, svc.ID)
		if err != nil {
			svclog.WithError(err).Debug("Could not retrieve instances for service")
			return nil, err
		}

		// set up the aggregated service object
		results[i] = service.AggregateService{
			ServiceID:         serviceID,
			Name:              svc.Name,
			DesiredState:      service.DesiredState(svc.DesiredState),
			CurrentState:      service.ServiceCurrentState(svc.CurrentState),
			Status:            make([]service.StatusInstance, len(stateIDs)),
			NotFound:          false,
			EmergencyShutdown: svc.EmergencyShutdown,
			RAMCommitment:     int64(svc.RAMCommitment.Value),
		}

		// set up the status of each instance
		for j, stateID := range stateIDs {

			// report the instance id and the health
			results[i].Status[j] = service.StatusInstance{
				InstanceID:   stateID.InstanceID,
				HealthStatus: f.getInstanceHealth(svc, stateID.InstanceID),
			}

			// append a request to the metrics query for this instance
			metricsreq = append(metricsreq, metrics.ServiceInstance{
				ServiceID:  serviceID,
				InstanceID: stateID.InstanceID,
			})

			// add the memory usage response
			instanceMap[fmt.Sprintf("%s-%d", serviceID, stateID.InstanceID)] = &results[i].Status[j].MemoryUsage
		}
	}

	// look up the metrics of all the instances
	metricsres, err := f.metricsClient.GetInstanceMemoryStats(since, metricsreq...)
	if err != nil {
		logger.WithError(err).Debug("Could not look up memory metrics for instances on service")
	} else {
		for _, metric := range metricsres {
			*instanceMap[fmt.Sprintf("%s-%s", metric.ServiceID, metric.InstanceID)] = service.Usage{
				Cur: metric.Last,
				Max: metric.Max,
				Avg: metric.Average,
			}
		}
	}

	logger.Debug("Loaded aggregate service instance data")
	return results, nil
}
534632
func (c *Catalog) ServiceMultipleTags(service string, tags []string, q *QueryOptions) ([]*CatalogService, *QueryMeta, error) {
	return c.service(service, tags, q, false)
}
929527
func (r *RoleBindingBuilder) Groups(groups ...string) *RoleBindingBuilder {
	for _, group := range groups {
		r.RoleBinding.Subjects = append(r.RoleBinding.Subjects, rbacv1.Subject{Kind: rbacv1.GroupKind, APIGroup: GroupName, Name: group})
	}
	return r
}