// One gets a specific issue based on the url of the service
//
// https://developer.github.com/v3/issues/#get-a-single-issue
421159
func (i *IssuesService) One(uri *Hyperlink, uriParams M) (issue *Issue, result *Result) {
	url, err := ExpandWithDefault(uri, &RepoIssuesURL, uriParams)
	if err != nil {
		return nil, &Result{Err: err}
	}

	result = i.client.get(url, &issue)
	return
}
286304
func (r *Repository) GetIssueCommentURL() string {
	if r == nil || r.IssueCommentURL == nil {
		return ""
	}
	return *r.IssueCommentURL
}
218723
func (l *MilestonesService) One(uri *Hyperlink, uriParams M) (milestone *Milestone, result *Result) {
	url, err := ExpandWithDefault(uri, &MilestonesURL, uriParams)
	if err != nil {
		return nil, &Result{Err: err}
	}

	result = l.client.get(url, &milestone)
	return
}
602214
func getWithStatusError(url string) (resp *http.Response, err error) {
	if resp, err = http.Get(url); err != nil {
		return nil, err
	}
	if resp.StatusCode < 400 {
		return resp, nil
	}
	msg := fmt.Sprintf("failed to GET %s with status %s", url, resp.Status)
	body, err := ioutil.ReadAll(resp.Body)
	resp.Body.Close()
	if err != nil {
		return nil, errors.Wrapf(err, msg+": error reading body")
	}
	return nil, errors.Errorf(msg+": %s", bytes.TrimSpace(body))
}
344047
func (o *querySet) One(container interface{}, cols ...string) error {
	num, err := o.orm.alias.DbBaser.ReadBatch(o.orm.db, o, o.mi, o.cond, container, o.orm.alias.TZ, cols)
	if err != nil {
		return err
	}
	if num > 1 {
		return ErrMultiRows
	}
	if num == 0 {
		return ErrNoRows
	}
	return nil
}
726784
func (u *UsersService) One() (user *User, result *Result) {
	result = u.client.get(u.URL, &user)
	return
}
103475
func (a *api) GetService(id string) (*service.Service, error) {
	client, err := a.connectDAO()
	if err != nil {
		return nil, err
	}

	var s service.Service
	if err := client.GetService(id, &s); err != nil {
		return nil, err
	}

	return &s, nil
}
179876
func (_m *RequesterVariadic) OneInterface(a ...interface{}) bool {
	var _ca []interface{}
	_ca = append(_ca, a...)
	ret := _m.Called(_ca...)

	var r0 bool
	if rf, ok := ret.Get(0).(func(...interface{}) bool); ok {
		r0 = rf(a...)
	} else {
		r0 = ret.Get(0).(bool)
	}

	return r0
}
1296862
func (tracker *issueTracker) issuesByNumber(issueNums []int) ([]*github.Issue, error) {
	task := "Get GitHub issues for the given issue numbers"

	// Prepare an accumulator.
	issues := make([]*github.Issue, 0, len(issueNums))

	// Send the requests concurrently.
	var (
		client = tracker.newClient()
		owner  = tracker.config.GitHubOwner
		repo   = tracker.config.GitHubRepository
	)
	ch := make(chan *getIssueResult, len(issueNums))
	for _, num := range issueNums {
		go func(issueNum int) {
			var (
				issue *github.Issue
				err   error
			)
			withRequestAllocated(func() {
				issue, _, err = client.Issues.Get(owner, repo, issueNum)
			})
			ch <- &getIssueResult{issue, err}
		}(num)
	}

	// Wait for the results to arrive.
	for i := 0; i < cap(ch); i++ {
		res := <-ch
		if err := res.err; err != nil {
			return nil, errs.NewError(task, err)
		}
		issues = append(issues, res.issue)
	}

	// Return the result.
	return issues, nil
}
691772
func One(f interface{}, a interface{}) interface{} {
	if f == nil {
		panic("f is required")
	}
	if a == nil {
		panic("a is required and cannot be nil")
	}

	fType := reflect.TypeOf(f)
	if fType.Kind() != reflect.Func {
		panic(fmt.Sprintf("%v (%v) is not a function", f, fType))
	}

	if fType.IsVariadic() {
		panic(fmt.Sprintf("%v (%v) is variadic", f, fType))
	}

	in := args(fType)
	out := returns(fType)
	if len(in) == 0 {
		panic(fmt.Sprintf("%v (%v) does not accept enough arguments to curry in %v", f, fType, a))
	}

	fVal := reflect.ValueOf(f)
	aVal := reflect.ValueOf(a)
	newFType := reflect.FuncOf(in[1:], out, false)
	return reflect.MakeFunc(newFType, func(args []reflect.Value) []reflect.Value {
		newArgs := make([]reflect.Value, 0, fType.NumIn())
		newArgs = append(newArgs, aVal)
		newArgs = append(newArgs, args...)
		return fVal.Call(newArgs)
	}).Interface()
}
444460
func (m *MetricResults) OneError() error {
	for _, r := range m.Results {
		if err := r.Error; err != nil {
			return err
		}
	}
	return nil
}
1198268
func (s *IssueService) List(params *IssueListParams) ([]Issue, *http.Response, error) {
	issues := new([]Issue)
	githubError := new(GithubError)
	resp, err := s.sling.New().Path("issues").QueryStruct(params).Receive(issues, githubError)
	if err == nil {
		err = githubError
	}
	return *issues, resp, err
}
358210
func (client *Client) GetRunstatusIncident(ctx context.Context, incident RunstatusIncident) (*RunstatusIncident, error) {
	if incident.URL != "" {
		return client.getRunstatusIncident(ctx, incident.URL)
	}

	if incident.PageURL == "" {
		return nil, fmt.Errorf("empty Page URL for %#v", incident)
	}

	page, err := client.getRunstatusPage(ctx, incident.PageURL)
	if err != nil {
		return nil, err
	}

	for i := range page.Incidents {
		j := &page.Incidents[i]
		if j.Match(incident) {
			return j, nil
		}
	}

	return nil, fmt.Errorf("%#v not found", incident)
}
716816
func (r *RootService) One() (root *Root, result *Result) {
	root = &Root{HALResource: &hypermedia.HALResource{}}
	result = r.client.get(r.URL, &root)
	if root != nil {
		// Cached hyperlinks
		root.PullsURL = hypermedia.Hyperlink(PullRequestsURL)
	}

	return
}
666832
func ParseReviewIssue(issue *github.Issue) (ReviewIssue, error) {
	// Use the title prefix to decide the review issue type.
	switch {
	case strings.HasPrefix(*issue.Title, "Review story"):
		return parseStoryReviewIssue(issue)
	case strings.HasPrefix(*issue.Title, "Review commit"):
		return parseCommitReviewIssue(issue)
	default:
		return nil, &ErrUnknownReviewIssueType{issue}
	}
}
926519
func One(arch, release, stream, ftype string, src func() simplestreams.DataSource) (*Metadata, error) {
	if err := validateArgs(arch, release, ftype); err != nil {
		return nil, errors.Trace(err)
	}
	if src == nil {
		src = DefaultSource
	}
	ds := []simplestreams.DataSource{src()}
	limit := imagemetadata.NewImageConstraint(
		simplestreams.LookupParams{
			Arches: []string{arch},
			Series: []string{release},
			Stream: stream,
		},
	)

	md, _, err := Fetch(ds, limit, Filter(ftype))
	if err != nil {
		// It doesn't appear that arch is vetted anywhere else so we can wind
		// up with empty results if someone requests any arch with valid series
		// and ftype..
		return nil, errors.Trace(err)
	}
	if len(md) < 1 {
		return nil, errors.Errorf("no results for %q, %q, %q, %q", arch, release, stream, ftype)
	}
	if len(md) > 1 {
		// Should not be possible.
		return nil, errors.Errorf("got %d results expected 1 for %q, %q, %q, %q", len(md), arch, release, stream, ftype)
	}
	return md[0], nil
}
461934
func (r *ViewResults) One(valuePtr interface{}) error {
	if !r.Next(valuePtr) {
		err := r.Close()
		if err != nil {
			return err
		}
		return noResultsError{}
	}

	// We have to purge the remaining rows in order to get to the remaining
	// response attributes
	for r.NextBytes() != nil {
	}

	err := r.Close()
	if err != nil {
		return err
	}

	return nil
}