// Stories returns user stories
//
// Use StoryMedia.Next for pagination.
//
// See example: examples/user/stories.go
483102
func (user *User) Stories() *StoryMedia {
	media := &StoryMedia{}
	media.uid = user.ID
	media.inst = user.inst
	media.endpoint = urlUserStories
	return media
}
1159023
func (leg *Leg) Recordings(client *messagebird.Client) *Paginator {
	return newPaginator(client, fmt.Sprintf("%s/calls/%s/legs/%s/recordings", apiRoot, leg.CallID, leg.ID), reflect.TypeOf(Recording{}))
}
251063
func (media *StoryMedia) Sync() error {
	insta := media.inst
	query := []trayRequest{
		{"SUPPORTED_SDK_VERSIONS", "9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0"},
		{"FACE_TRACKER_VERSION", "10"},
		{"segmentation", "segmentation_enabled"},
		{"COMPRESSION", "ETC2_COMPRESSION"},
	}
	qjson, err := json.Marshal(query)
	if err != nil {
		return err
	}

	id := media.Pk.(string)
	data, err := insta.prepareData(
		map[string]interface{}{
			"user_ids":                   []string{id},
			"supported_capabilities_new": b2s(qjson),
		},
	)
	if err != nil {
		return err
	}

	body, err := insta.sendRequest(
		&reqOptions{
			Endpoint: urlReelMedia,
			Query:    generateSignature(data),
			IsPost:   true,
		},
	)
	if err == nil {
		resp := trayResp{}
		err = json.Unmarshal(body, &resp)
		if err == nil {
			m, ok := resp.Reels[id]
			if ok {
				media.Items = m.Items
				media.setValues()
				return nil
			}
			err = fmt.Errorf("cannot find %s structure in response", id)
		}
	}
	return err
}
540763
func (m *Mux) Build(handlers []Handler) (http.Handler, error) {
	recordMap := make(map[string][]Record)
	for _, h := range handlers {
		recordMap[h.Method] = append(recordMap[h.Method], NewRecord(h.Path, h.Func))
	}
	mux := newServeMux()
	for m, records := range recordMap {
		router := New()
		if err := router.Build(records); err != nil {
			return nil, err
		}
		mux.routers[m] = router
	}
	return mux, nil
}
567639
func (c *UsergroupsCreateCall) Channels(channels string) *UsergroupsCreateCall {
	c.channels = channels
	return c
}
175873
func (dialog *Dialog) Run(stories []common.Story) (common.Story, error) {
	// Return an error when no options are set.
	if len(dialog.opts) == 0 {
		return nil, errors.New("storyprompt.Dialog.Run(): no options were specified")
	}

	// Increment the dialog depth on enter.
	dialog.depth++
	// Decrement the dialog depth on return.
	defer func() {
		dialog.depth--
	}()

	// Enter the dialog loop.
DialogLoop:
	for {
		var (
			opts  = dialog.opts
			depth = dialog.depth
		)

		// Present the stories to the user.
		if err := ListStories(stories, os.Stdout); err != nil {
			return nil, err
		}

		// Print the options based on the dialog depth.
		fmt.Println()
		fmt.Println("Now you can do one of the following:")
		fmt.Println()

		// Collect the list of active options.
		activeOpts := make([]*DialogOption, 0, len(opts))
		for _, opt := range opts {
			if isActive := opt.IsActive; isActive != nil && isActive(stories, depth) {
				activeOpts = append(activeOpts, opt)
			}
		}

		// Print the description for the active options.
		for _, opt := range activeOpts {
			if desc := opt.Description; len(desc) != 0 {
				fmt.Println("  -", strings.Join(desc, "\n    "))
			}
		}
		fmt.Println()

		// Prompt the user for their choice.
		fmt.Println("Current dialog depth:", depth)
		input, err := prompt.Prompt("Choose what to do next: ")
		// We ignore prompt.ErrCanceled here and simply continue.
		// That is because an empty input is a valid input here as well.
		if err != nil && err != prompt.ErrCanceled {
			return nil, err
		}
		input = strings.TrimSpace(input)

		// Find the first matching option.
		var matchingOpt *DialogOption
		for _, opt := range activeOpts {
			if matchFunc := opt.MatchesInput; matchFunc != nil && matchFunc(input, stories) {
				matchingOpt = opt
				break
			}
		}
		// Loop again in case no match is found.
		if matchingOpt == nil {
			fmt.Println()
			fmt.Println("Error: no matching option found")
			fmt.Println()
			continue DialogLoop
		}

		// Run the selected select function.
		if selectFunc := matchingOpt.SelectStory; selectFunc != nil {
			story, err := selectFunc(input, stories, dialog)
			if err != nil {
				switch err {
				case ErrContinue:
					// Continue looping on ErrContinue.
					fmt.Println()
					continue DialogLoop
				case ErrReturn:
					// Go one dialog up by returning ErrContinue.
					// This makes the dialog loop of the parent dialog continue,
					// effectively re-printing and re-running that dialog.
					if dialog.isSub {
						return nil, ErrContinue
					}

					// In case this is a top-level dialog, abort.
					fallthrough
				case ErrAbort:
					// Panic prompt.ErrCanceled on ErrAbort, returning immediately
					// from any dialog depth.
					prompt.PanicCancel()
				}

				// In case the error is not any of the recognized control errors,
				// print the error and loop again, making the user choose again.
				fmt.Println()
				fmt.Println("Error:", err)
				fmt.Println()
				continue DialogLoop
			}
			return story, nil
		}

		// No SelectStory function specified for the matching option,
		// that is a programming error, let's just panic.
		panic(errors.New("SelectStory function not specified"))
	}
}
972462
func (d Data) Pages() Pages {
	v, found := d["pages"]
	if !found {
		return nil
	}

	switch vv := v.(type) {
	case Pages:
		return vv
	case func() Pages:
		return vv()
	default:
		panic(fmt.Sprintf("%T is not Pages", v))
	}
}
1350678
func NewSessions(c config.Cookie, conn sol.Conn) *SessionManager {
	return &SessionManager{
		conn:    conn,
		cookie:  c,
		keyFunc: RandomKey,
		nowFunc: func() time.Time { return time.Now().In(time.UTC) },
	}
}
641136
func (pr *PagingResult) Next() (noMore bool, err error) {
	if !pr.HasNext() {
		noMore = true
		return
	}

	return pr.navigate(&pr.next)
}
34716
func newServices(c *CoreClient, namespace string) *services {
	return &services{
		client: c,
		ns:     namespace,
	}
}
1200386
func (c *collectorImpl) GetUserRecords() map[string]*collector.UserRecord {
	c.Lock()
	defer c.Unlock()

	if len(c.Users) == 0 {
		return nil
	}

	retval := c.Users
	c.Users = map[string]*collector.UserRecord{}
	return retval
}
498233
func (m *Model) Users() ([]permission.UserAccess, error) {
	coll, closer := m.st.db().GetCollection(modelUsersC)
	defer closer()

	var userDocs []userAccessDoc
	err := coll.Find(nil).All(&userDocs)
	if err != nil {
		return nil, errors.Trace(err)
	}

	var modelUsers []permission.UserAccess
	for _, doc := range userDocs {
		// check if the User belonging to this model user has
		// been deleted, in this case we should not return it.
		userTag := names.NewUserTag(doc.UserName)
		if userTag.IsLocal() {
			_, err := m.st.User(userTag)
			if err != nil {
				if _, ok := err.(DeletedUserError); !ok {
					// We ignore deleted users for now. So if it is not a
					// DeletedUserError we return the error.
					return nil, errors.Trace(err)
				}
				continue
			}
		}
		mu, err := NewModelUserAccess(m.st, doc)
		if err != nil {
			return nil, errors.Trace(err)
		}
		modelUsers = append(modelUsers, mu)
	}

	return modelUsers, nil
}
1165045
func NewUserHistory(log logger.Logger, vlog *libkb.VDebugLog) *UserHistory {
	return &UserHistory{
		histories: make(map[tlfKey]writersByRevision),
		log:       log,
		vlog:      vlog,
	}
}
314933
func (po *PageOptions) Args() []string {
	return append(append([]string{}, po.pageOptions.Args()...), po.headerAndFooterOptions.Args()...)
}
88274
func (s *Service) Users(w http.ResponseWriter, r *http.Request) {
	ctx := r.Context()

	users, err := s.Store.Users(ctx).All(ctx)
	if err != nil {
		Error(w, http.StatusBadRequest, err.Error(), s.Logger)
		return
	}

	orgID := httprouter.GetParamFromContext(ctx, "oid")
	res := newUsersResponse(users, orgID)
	encodeJSON(w, http.StatusOK, res, s.Logger)
}
312764
func (tracker *issueTracker) ReviewedStories() (stories []common.Story, err error) {
	return tracker.searchIssuesAndWrap(`state:open label:"%v"`, tracker.config.ReviewedLabel)
}
1182186
func (o *Enterprise) Users(info *bambou.FetchingInfo) (UsersList, *bambou.Error) {

	var list UsersList
	err := bambou.CurrentSession().FetchChildren(o, UserIdentity, &list, info)
	return list, err
}