func (r *ReposReq) Rel(link string, resp *ReposResponse) bool {
	u := getRelLink(resp.HTTPResponse(), link)
	if u == "" {
		return false
	}
	r._url = u
	return true
}
/*
Rel updates this request to point to a relative link from resp. Returns false if
the link does not exist. Handy for paging.
package search
import (
	"context"
	"fmt"
	components "github.com/willabides/octo-go/components"
	requests "github.com/willabides/octo-go/requests"
	"net/http"
	"net/url"
	"strconv"
)
func Code(ctx context.Context, req *CodeReq, opt ...requests.Option) (*CodeResponse, error) {
	opts := requests.BuildOptions(opt...)
	if req == nil {
		req = new(CodeReq)
	}
	resp := &CodeResponse{}
	httpReq, err := req.HTTPRequest(ctx, opt...)
	if err != nil {
		return nil, err
	}
	r, err := opts.HttpClient().Do(httpReq)
	if err != nil {
		return nil, err
	}
	err = resp.ReadResponse(r)
	if err != nil {
		return nil, err
	}
	return resp, nil
}
func (c Client) Code(ctx context.Context, req *CodeReq, opt ...requests.Option) (*CodeResponse, error) {
	return Code(ctx, req, append(c, opt...)...)
}
type CodeReq struct {
	_url string
	Q *string
	Sort *string
	Order *string
	PerPage *int64
	Page *int64
}
func (r *CodeReq) HTTPRequest(ctx context.Context, opt ...requests.Option) (*http.Request, error) {
	query := url.Values{}
	if r.Q != nil {
		query.Set("q", *r.Q)
	}
	if r.Sort != nil {
		query.Set("sort", *r.Sort)
	}
	if r.Order != nil {
		query.Set("order", *r.Order)
	}
	if r.PerPage != nil {
		query.Set("per_page", strconv.FormatInt(*r.PerPage, 10))
	}
	if r.Page != nil {
		query.Set("page", strconv.FormatInt(*r.Page, 10))
	}
	return buildHTTPRequest(ctx, buildHTTPRequestOptions{
		ExplicitURL: r._url,
		HeaderVals:  map[string]*string{"accept": strPtr("application/json")},
		Method:      "GET",
		Options:     opt,
		URLPath:     fmt.Sprintf("/search/code"),
		URLQuery:    query,
	})
}
func (r *CodeReq) Rel(link string, resp *CodeResponse) bool {
	u := getRelLink(resp.HTTPResponse(), link)
	if u == "" {
		return false
	}
	r._url = u
	return true
}
type CodeResponseBody struct {
	IncompleteResults bool                              `json:"incomplete_results,omitempty"`
	Items             []components.CodeSearchResultItem `json:"items,omitempty"`
	TotalCount        int64                             `json:"total_count,omitempty"`
}
type CodeResponse struct {
	httpResponse *http.Response
	Data         CodeResponseBody
}
func (r *CodeResponse) HTTPResponse() *http.Response {
	return r.httpResponse
}
func (r *CodeResponse) ReadResponse(resp *http.Response) error {
	r.httpResponse = resp
	err := responseErrorCheck(resp, []int{200, 304})
	if err != nil {
		return err
	}
	if intInSlice(resp.StatusCode, []int{200}) {
		err = unmarshalResponseBody(resp, &r.Data)
		if err != nil {
			return err
		}
	}
	return nil
}
func Commits(ctx context.Context, req *CommitsReq, opt ...requests.Option) (*CommitsResponse, error) {
	opts := requests.BuildOptions(opt...)
	if req == nil {
		req = new(CommitsReq)
	}
	resp := &CommitsResponse{}
	httpReq, err := req.HTTPRequest(ctx, opt...)
	if err != nil {
		return nil, err
	}
	r, err := opts.HttpClient().Do(httpReq)
	if err != nil {
		return nil, err
	}
	err = resp.ReadResponse(r)
	if err != nil {
		return nil, err
	}
	return resp, nil
}
func (c Client) Commits(ctx context.Context, req *CommitsReq, opt ...requests.Option) (*CommitsResponse, error) {
	return Commits(ctx, req, append(c, opt...)...)
}
type CommitsReq struct {
	_url string
	Q *string
	Sort *string
	Order *string
	PerPage *int64
	Page *int64
	CloakPreview bool
}
func (r *CommitsReq) HTTPRequest(ctx context.Context, opt ...requests.Option) (*http.Request, error) {
	query := url.Values{}
	if r.Q != nil {
		query.Set("q", *r.Q)
	}
	if r.Sort != nil {
		query.Set("sort", *r.Sort)
	}
	if r.Order != nil {
		query.Set("order", *r.Order)
	}
	if r.PerPage != nil {
		query.Set("per_page", strconv.FormatInt(*r.PerPage, 10))
	}
	if r.Page != nil {
		query.Set("page", strconv.FormatInt(*r.Page, 10))
	}
	return buildHTTPRequest(ctx, buildHTTPRequestOptions{
		AllPreviews:      []string{"cloak"},
		ExplicitURL:      r._url,
		HeaderVals:       map[string]*string{"accept": strPtr("application/json")},
		Method:           "GET",
		Options:          opt,
		Previews:         map[string]bool{"cloak": r.CloakPreview},
		RequiredPreviews: []string{"cloak"},
		URLPath:          fmt.Sprintf("/search/commits"),
		URLQuery:         query,
	})
}
func (r *CommitsReq) Rel(link string, resp *CommitsResponse) bool {
	u := getRelLink(resp.HTTPResponse(), link)
	if u == "" {
		return false
	}
	r._url = u
	return true
}
type CommitsResponseBody struct {
	IncompleteResults bool                                `json:"incomplete_results,omitempty"`
	Items             []components.CommitSearchResultItem `json:"items,omitempty"`
	TotalCount        int64                               `json:"total_count,omitempty"`
}
type CommitsResponse struct {
	httpResponse *http.Response
	Data         CommitsResponseBody
}
func (r *CommitsResponse) HTTPResponse() *http.Response {
	return r.httpResponse
}
func (r *CommitsResponse) ReadResponse(resp *http.Response) error {
	r.httpResponse = resp
	err := responseErrorCheck(resp, []int{200, 304})
	if err != nil {
		return err
	}
	if intInSlice(resp.StatusCode, []int{200}) {
		err = unmarshalResponseBody(resp, &r.Data)
		if err != nil {
			return err
		}
	}
	return nil
}
func IssuesAndPullRequests(ctx context.Context, req *IssuesAndPullRequestsReq, opt ...requests.Option) (*IssuesAndPullRequestsResponse, error) {
	opts := requests.BuildOptions(opt...)
	if req == nil {
		req = new(IssuesAndPullRequestsReq)
	}
	resp := &IssuesAndPullRequestsResponse{}
	httpReq, err := req.HTTPRequest(ctx, opt...)
	if err != nil {
		return nil, err
	}
	r, err := opts.HttpClient().Do(httpReq)
	if err != nil {
		return nil, err
	}
	err = resp.ReadResponse(r)
	if err != nil {
		return nil, err
	}
	return resp, nil
}
func (c Client) IssuesAndPullRequests(ctx context.Context, req *IssuesAndPullRequestsReq, opt ...requests.Option) (*IssuesAndPullRequestsResponse, error) {
	return IssuesAndPullRequests(ctx, req, append(c, opt...)...)
}
type IssuesAndPullRequestsReq struct {
	_url string
	Q *string
	Sort *string
	Order *string
	PerPage *int64
	Page *int64
}
func (r *IssuesAndPullRequestsReq) HTTPRequest(ctx context.Context, opt ...requests.Option) (*http.Request, error) {
	query := url.Values{}
	if r.Q != nil {
		query.Set("q", *r.Q)
	}
	if r.Sort != nil {
		query.Set("sort", *r.Sort)
	}
	if r.Order != nil {
		query.Set("order", *r.Order)
	}
	if r.PerPage != nil {
		query.Set("per_page", strconv.FormatInt(*r.PerPage, 10))
	}
	if r.Page != nil {
		query.Set("page", strconv.FormatInt(*r.Page, 10))
	}
	return buildHTTPRequest(ctx, buildHTTPRequestOptions{
		ExplicitURL: r._url,
		HeaderVals:  map[string]*string{"accept": strPtr("application/json")},
		Method:      "GET",
		Options:     opt,
		URLPath:     fmt.Sprintf("/search/issues"),
		URLQuery:    query,
	})
}
func (r *IssuesAndPullRequestsReq) Rel(link string, resp *IssuesAndPullRequestsResponse) bool {
	u := getRelLink(resp.HTTPResponse(), link)
	if u == "" {
		return false
	}
	r._url = u
	return true
}
type IssuesAndPullRequestsResponseBody struct {
	IncompleteResults bool                               `json:"incomplete_results,omitempty"`
	Items             []components.IssueSearchResultItem `json:"items,omitempty"`
	TotalCount        int64                              `json:"total_count,omitempty"`
}
type IssuesAndPullRequestsResponse struct {
	httpResponse *http.Response
	Data         IssuesAndPullRequestsResponseBody
}
func (r *IssuesAndPullRequestsResponse) HTTPResponse() *http.Response {
	return r.httpResponse
}
func (r *IssuesAndPullRequestsResponse) ReadResponse(resp *http.Response) error {
	r.httpResponse = resp
	err := responseErrorCheck(resp, []int{200, 304})
	if err != nil {
		return err
	}
	if intInSlice(resp.StatusCode, []int{200}) {
		err = unmarshalResponseBody(resp, &r.Data)
		if err != nil {
			return err
		}
	}
	return nil
}
func Labels(ctx context.Context, req *LabelsReq, opt ...requests.Option) (*LabelsResponse, error) {
	opts := requests.BuildOptions(opt...)
	if req == nil {
		req = new(LabelsReq)
	}
	resp := &LabelsResponse{}
	httpReq, err := req.HTTPRequest(ctx, opt...)
	if err != nil {
		return nil, err
	}
	r, err := opts.HttpClient().Do(httpReq)
	if err != nil {
		return nil, err
	}
	err = resp.ReadResponse(r)
	if err != nil {
		return nil, err
	}
	return resp, nil
}
func (c Client) Labels(ctx context.Context, req *LabelsReq, opt ...requests.Option) (*LabelsResponse, error) {
	return Labels(ctx, req, append(c, opt...)...)
}
type LabelsReq struct {
	_url string
	RepositoryId *int64
	Q *string
	Sort *string
	Order *string
}
func (r *LabelsReq) HTTPRequest(ctx context.Context, opt ...requests.Option) (*http.Request, error) {
	query := url.Values{}
	if r.RepositoryId != nil {
		query.Set("repository_id", strconv.FormatInt(*r.RepositoryId, 10))
	}
	if r.Q != nil {
		query.Set("q", *r.Q)
	}
	if r.Sort != nil {
		query.Set("sort", *r.Sort)
	}
	if r.Order != nil {
		query.Set("order", *r.Order)
	}
	return buildHTTPRequest(ctx, buildHTTPRequestOptions{
		ExplicitURL: r._url,
		HeaderVals:  map[string]*string{"accept": strPtr("application/json")},
		Method:      "GET",
		Options:     opt,
		URLPath:     fmt.Sprintf("/search/labels"),
		URLQuery:    query,
	})
}
func (r *LabelsReq) Rel(link string, resp *LabelsResponse) bool {
	u := getRelLink(resp.HTTPResponse(), link)
	if u == "" {
		return false
	}
	r._url = u
	return true
}
type LabelsResponseBody struct {
	IncompleteResults bool                               `json:"incomplete_results,omitempty"`
	Items             []components.LabelSearchResultItem `json:"items,omitempty"`
	TotalCount        int64                              `json:"total_count,omitempty"`
}
type LabelsResponse struct {
	httpResponse *http.Response
	Data         LabelsResponseBody
}
func (r *LabelsResponse) HTTPResponse() *http.Response {
	return r.httpResponse
}
func (r *LabelsResponse) ReadResponse(resp *http.Response) error {
	r.httpResponse = resp
	err := responseErrorCheck(resp, []int{200, 304})
	if err != nil {
		return err
	}
	if intInSlice(resp.StatusCode, []int{200}) {
		err = unmarshalResponseBody(resp, &r.Data)
		if err != nil {
			return err
		}
	}
	return nil
}
func Repos(ctx context.Context, req *ReposReq, opt ...requests.Option) (*ReposResponse, error) {
	opts := requests.BuildOptions(opt...)
	if req == nil {
		req = new(ReposReq)
	}
	resp := &ReposResponse{}
	httpReq, err := req.HTTPRequest(ctx, opt...)
	if err != nil {
		return nil, err
	}
	r, err := opts.HttpClient().Do(httpReq)
	if err != nil {
		return nil, err
	}
	err = resp.ReadResponse(r)
	if err != nil {
		return nil, err
	}
	return resp, nil
}
func (c Client) Repos(ctx context.Context, req *ReposReq, opt ...requests.Option) (*ReposResponse, error) {
	return Repos(ctx, req, append(c, opt...)...)
}
type ReposReq struct {
	_url string
	Q *string
	Sort *string
	Order *string
	PerPage *int64
	Page *int64
	MercyPreview bool
}
func (r *ReposReq) HTTPRequest(ctx context.Context, opt ...requests.Option) (*http.Request, error) {
	query := url.Values{}
	if r.Q != nil {
		query.Set("q", *r.Q)
	}
	if r.Sort != nil {
		query.Set("sort", *r.Sort)
	}
	if r.Order != nil {
		query.Set("order", *r.Order)
	}
	if r.PerPage != nil {
		query.Set("per_page", strconv.FormatInt(*r.PerPage, 10))
	}
	if r.Page != nil {
		query.Set("page", strconv.FormatInt(*r.Page, 10))
	}
	return buildHTTPRequest(ctx, buildHTTPRequestOptions{
		AllPreviews: []string{"mercy"},
		ExplicitURL: r._url,
		HeaderVals:  map[string]*string{"accept": strPtr("application/json")},
		Method:      "GET",
		Options:     opt,
		Previews:    map[string]bool{"mercy": r.MercyPreview},
		URLPath:     fmt.Sprintf("/search/repositories"),
		URLQuery:    query,
	})
}