// ListServiceHooks lists all of the available service hooks.
//
// GitHub API docs: https://developer.github.com/webhooks/#services
167866
func (c *Client) ListServiceHooks(ctx context.Context) ([]*ServiceHook, *Response, error) {
	u := "hooks"
	req, err := c.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	var hooks []*ServiceHook
	resp, err := c.Do(ctx, req, &hooks)
	if err != nil {
		return nil, resp, err
	}

	return hooks, resp, nil
}
137668
func (s *ServicesService) List(options *ListServicesOptions) ([]*Service, *http.Response, error) {
	return s.ListWithContext(context.TODO(), options)
}
1129584
func (wb *Webhooks) AvailableWebhooks() []Webhook {
	webhooks := make([]Webhook, 0)
	s := reflect.ValueOf(wb).Elem()
	for i := 0; i < s.NumField(); i++ {
		f := s.Field(i)

		if !f.CanInterface() {
			continue
		}

		if wbPlugin, ok := f.Interface().(Webhook); ok {
			if !reflect.ValueOf(wbPlugin).IsNil() {
				webhooks = append(webhooks, wbPlugin)
			}
		}
	}

	return webhooks
}
110267
func (s *AppsService) ListRepos(ctx context.Context, opt *ListOptions) ([]*Repository, *Response, error) {
	u, err := addOptions("installation/repositories", opt)
	if err != nil {
		return nil, nil, err
	}

	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	// TODO: remove custom Accept header when this API fully launches.
	req.Header.Set("Accept", mediaTypeIntegrationPreview)

	var r struct {
		Repositories []*Repository `json:"repositories"`
	}
	resp, err := s.client.Do(ctx, req, &r)
	if err != nil {
		return nil, resp, err
	}

	return r.Repositories, resp, nil
}
1083590
func (c *Manager) ListLibraries(ctx context.Context) ([]string, error) {
	url := internal.URL(c, internal.LibraryPath)
	var res []string
	return res, c.Do(ctx, url.Request(http.MethodGet), &res)
}
17652
func listServiceLB(ctx *cli.Context) {

	tenantName := ctx.String("tenant")
	if len(tenantName) == 0 {
		tenantName = "default"
	}
	_, err := getClient(ctx).TenantGet(tenantName)
	errCheck(ctx, err)

	svcList, err := getClient(ctx).ServiceLBList()
	errCheck(ctx, err)

	filtered := []*contivClient.ServiceLB{}

	if ctx.Bool("all") {
		filtered = *svcList
	} else {
		for _, svc := range *svcList {
			if svc.TenantName == tenantName {
				filtered = append(filtered, svc)
			}
		}
	}

	if ctx.Bool("json") {
		dumpJSONList(ctx, filtered)
	} else if ctx.Bool("quiet") {
		services := ""
		for _, service := range filtered {
			services += service.ServiceName + "\n"
		}
		os.Stdout.WriteString(services)
	} else {

		writer := tabwriter.NewWriter(os.Stdout, 0, 2, 2, ' ', 0)
		defer writer.Flush()
		writer.Write([]byte("ServiceName\tTenant\tNetwork\tSelectors\n"))
		writer.Write([]byte("---------\t--------\t-------\t-------\n"))
		for _, group := range filtered {
			writer.Write(
				[]byte(fmt.Sprintf("%v\t%v\t%v\t%v\t\n",
					group.ServiceName,
					group.TenantName,
					group.NetworkName,
					group.Selectors,
				)))
		}
	}
}
477100
func (*Service) ListOSes(c context.Context, req *crimson.ListOSesRequest) (*crimson.ListOSesResponse, error) {
	oses, err := listOSes(c, stringset.NewFromSlice(req.Names...))
	if err != nil {
		return nil, err
	}
	return &crimson.ListOSesResponse{
		Oses: oses,
	}, nil
}
112638
func (c *Client) ListServiceUsageEventsByQuery(query url.Values) ([]ServiceUsageEvent, error) {
	var serviceUsageEvents []ServiceUsageEvent
	requestURL := fmt.Sprintf("/v2/service_usage_events?%s", query.Encode())
	for {
		var serviceUsageEventsResponse ServiceUsageEventsResponse
		r := c.NewRequest("GET", requestURL)
		resp, err := c.DoRequest(r)
		if err != nil {
			return nil, errors.Wrap(err, "error requesting events")
		}
		defer resp.Body.Close()
		if err := json.NewDecoder(resp.Body).Decode(&serviceUsageEventsResponse); err != nil {
			return nil, errors.Wrap(err, "error unmarshaling events")
		}
		for _, e := range serviceUsageEventsResponse.Resources {
			e.Entity.GUID = e.Meta.Guid
			e.Entity.CreatedAt = e.Meta.CreatedAt
			e.Entity.c = c
			serviceUsageEvents = append(serviceUsageEvents, e.Entity)
		}
		requestURL = serviceUsageEventsResponse.NextURL
		if requestURL == "" {
			break
		}
	}
	return serviceUsageEvents, nil
}
371119
func listServicesWithOptions(ctx context.Context, p listServicesWithoutOptionsClient, opts v11.ListServicesOptions, supportedKinds []string) ([]v6.ControllerStatus, error) {
	if opts.Namespace != "" && len(opts.Services) > 0 {
		return nil, errors.New("cannot filter by 'namespace' and 'services' at the same time")
	}
	if len(supportedKinds) > 0 {
		for _, svc := range opts.Services {
			if err := requireServiceIDKinds(svc, supportedKinds); err != nil {
				return nil, remote.UnsupportedResourceKind(err)
			}
		}
	}

	all, err := p.ListServices(ctx, opts.Namespace)
	listServicesRolloutStatus(all)
	if err != nil {
		return nil, err
	}
	if len(opts.Services) == 0 {
		return all, nil
	}

	// Polyfill the service IDs filter
	want := map[flux.ResourceID]struct{}{}
	for _, svc := range opts.Services {
		want[svc] = struct{}{}
	}
	var controllers []v6.ControllerStatus
	for _, svc := range all {
		if _, ok := want[svc.ID]; ok {
			controllers = append(controllers, svc)
		}
	}
	return controllers, nil
}
1259003
func ServiceSearch(args filters.Args) (services []swarm.Service, err error) { // nolint: gocyclo
	err = mgr.Do(func(ctx context.Context, cli *client.Client) (err error) {
		opts := types.ServiceListOptions{Filters: args}
		services, err = cli.ServiceList(ctx, opts)
		return
	})
	return
}
588563
func ListServices() ([]string, error) {
	fis, err := ioutil.ReadDir(InitDir)
	if err != nil {
		return nil, errors.Trace(err)
	}

	var services []string
	for _, fi := range fis {
		if groups := servicesRe.FindStringSubmatch(fi.Name()); len(groups) > 0 {
			services = append(services, groups[1])
		}
	}
	return services, nil
}
91794
func (s *RedisAnnouncementStore) ListService(serviceName string, opts *storage.ListOptions) ([]*Announcement, error) {
	announcementsI, err := s.store.List(serviceName+":*", opts)
	if err != nil {
		return nil, err
	}
	announcements := make([]*Announcement, len(announcementsI))
	for i, announcementI := range announcementsI {
		if announcement, ok := announcementI.(Announcement); ok {
			announcements[i] = &announcement
			announcement.Metadata, err = s.GetMetadata(announcement.ServiceName, announcement.ID)
			if err != nil {
				return nil, err
			}
		}
	}
	return announcements, nil
}
1033554
func StackList() (stacks []*model.Stack, err error) {
	err = mgr.Do(func(ctx context.Context, cli *client.Client) (err error) {
		var services []swarm.Service
		opts := types.ServiceListOptions{
			Filters: filters.NewArgs(),
		}
		opts.Filters.Add("label", stackLabel)
		services, err = cli.ServiceList(ctx, opts)
		if err != nil {
			return
		}

		m := make(map[string]*model.Stack)
		for _, service := range services {
			labels := service.Spec.Labels
			name, ok := labels[stackLabel]
			if !ok {
				err = fmt.Errorf("cannot get label %s for service %s(%s)", stackLabel, service.Spec.Name, service.ID)
				return
			}

			if stack, ok := m[name]; ok {
				stack.Services = append(stack.Services, service.Spec.Name)
			} else {
				m[name] = &model.Stack{
					Name:     name,
					Services: []string{service.Spec.Name},
				}
			}
		}

		for _, stack := range m {
			stacks = append(stacks, stack)
		}
		sort.Slice(stacks, func(i, j int) bool {
			return stacks[i].Name < stacks[j].Name
		})
		return
	})
	return
}
1259235
func ListServicesScript() string {
	commands := []string{
		"init_system=$(" + DiscoverInitSystemScript() + ")",
		// If the init system is not identified then the script will
		// "exit 1". This is correct since the script should fail if no
		// init system can be identified.
		newShellSelectCommand("init_system", "exit 1", listServicesCommand),
	}
	return strings.Join(commands, "\n")
}
880568
func ListHooks(repoPath string) (_ []*Hook, err error) {
	if !isDir(path.Join(repoPath, "hooks")) {
		return nil, errors.New("hooks path does not exist")
	}

	hooks := make([]*Hook, len(HookNames))
	for i, name := range HookNames {
		hooks[i], err = GetHook(repoPath, name)
		if err != nil {
			return nil, err
		}
	}
	return hooks, nil
}
841042
func (ctx *Context) ListServices() ([]string, error) {
	ctx.mutex.RLock()
	defer ctx.mutex.RUnlock()

	r := make([]string, 0, len(ctx.services))

	for vsID := range ctx.services {
		r = append(r, vsID)
	}

	return r, nil
}
334134
func (c *Client) ListS3s(i *ListS3sInput) ([]*S3, error) {
	if i.Service == "" {
		return nil, ErrMissingService
	}

	if i.Version == 0 {
		return nil, ErrMissingVersion
	}

	path := fmt.Sprintf("/service/%s/version/%d/logging/s3", i.Service, i.Version)
	resp, err := c.Get(path, nil)
	if err != nil {
		return nil, err
	}

	var s3s []*S3
	if err := decodeJSON(&s3s, resp.Body); err != nil {
		return nil, err
	}
	sort.Stable(s3sByName(s3s))
	return s3s, nil
}