// Code generated by go-swagger; DO NOT EDIT.

package issue

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"context"
	"net/http"
	"time"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/runtime"
	cr "github.com/go-openapi/runtime/client"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
)

// NewIssueListIssuesParams creates a new IssueListIssuesParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewIssueListIssuesParams() *IssueListIssuesParams {
	return &IssueListIssuesParams{
		timeout: cr.DefaultTimeout,
	}
}

// NewIssueListIssuesParamsWithTimeout creates a new IssueListIssuesParams object
// with the ability to set a timeout on a request.
func NewIssueListIssuesParamsWithTimeout(timeout time.Duration) *IssueListIssuesParams {
	return &IssueListIssuesParams{
		timeout: timeout,
	}
}

// NewIssueListIssuesParamsWithContext creates a new IssueListIssuesParams object
// with the ability to set a context for a request.
func NewIssueListIssuesParamsWithContext(ctx context.Context) *IssueListIssuesParams {
	return &IssueListIssuesParams{
		Context: ctx,
	}
}

// NewIssueListIssuesParamsWithHTTPClient creates a new IssueListIssuesParams object
// with the ability to set a custom HTTPClient for a request.
func NewIssueListIssuesParamsWithHTTPClient(client *http.Client) *IssueListIssuesParams {
	return &IssueListIssuesParams{
		HTTPClient: client,
	}
}

/*
IssueListIssuesParams contains all the parameters to send to the API endpoint

	for the issue list issues operation.

	Typically these are written to a http.Request.
*/
type IssueListIssuesParams struct {

	/* AssignedBy.

	   Only show items for which the given user is assigned
	*/
	AssignedBy *string

	/* Before.

	   Only show items updated before the given time. This is a timestamp in RFC 3339 format

	   Format: date-time
	*/
	Before *strfmt.DateTime

	/* CreatedBy.

	   Only show items which were created by the given user
	*/
	CreatedBy *string

	/* Labels.

	   comma separated list of labels. Fetch only issues that have any of this labels. Non existent labels are discarded
	*/
	Labels *string

	/* Limit.

	   page size of results
	*/
	Limit *int64

	/* MentionedBy.

	   Only show items in which the given user was mentioned
	*/
	MentionedBy *string

	/* Milestones.

	   comma separated list of milestone names or ids. It uses names and fall back to ids. Fetch only issues that have any of this milestones. Non existent milestones are discarded
	*/
	Milestones *string

	/* Owner.

	   owner of the repo
	*/
	Owner string

	/* Page.

	   page number of results to return (1-based)
	*/
	Page *int64

	/* Q.

	   search string
	*/
	Q *string

	/* Repo.

	   name of the repo
	*/
	Repo string

	/* Since.

	   Only show items updated after the given time. This is a timestamp in RFC 3339 format

	   Format: date-time
	*/
	Since *strfmt.DateTime

	/* State.

	   whether issue is open or closed
	*/
	State *string

	/* Type.

	   filter by type (issues / pulls) if set
	*/
	Type *string

	timeout    time.Duration
	Context    context.Context
	HTTPClient *http.Client
}

// WithDefaults hydrates default values in the issue list issues params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *IssueListIssuesParams) WithDefaults() *IssueListIssuesParams {
	o.SetDefaults()
	return o
}

// SetDefaults hydrates default values in the issue list issues params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *IssueListIssuesParams) SetDefaults() {
	// no default values defined for this parameter
}

// WithTimeout adds the timeout to the issue list issues params
func (o *IssueListIssuesParams) WithTimeout(timeout time.Duration) *IssueListIssuesParams {
	o.SetTimeout(timeout)
	return o
}

// SetTimeout adds the timeout to the issue list issues params
func (o *IssueListIssuesParams) SetTimeout(timeout time.Duration) {
	o.timeout = timeout
}

// WithContext adds the context to the issue list issues params
func (o *IssueListIssuesParams) WithContext(ctx context.Context) *IssueListIssuesParams {
	o.SetContext(ctx)
	return o
}

// SetContext adds the context to the issue list issues params
func (o *IssueListIssuesParams) SetContext(ctx context.Context) {
	o.Context = ctx
}

// WithHTTPClient adds the HTTPClient to the issue list issues params
func (o *IssueListIssuesParams) WithHTTPClient(client *http.Client) *IssueListIssuesParams {
	o.SetHTTPClient(client)
	return o
}

// SetHTTPClient adds the HTTPClient to the issue list issues params
func (o *IssueListIssuesParams) SetHTTPClient(client *http.Client) {
	o.HTTPClient = client
}

// WithAssignedBy adds the assignedBy to the issue list issues params
func (o *IssueListIssuesParams) WithAssignedBy(assignedBy *string) *IssueListIssuesParams {
	o.SetAssignedBy(assignedBy)
	return o
}

// SetAssignedBy adds the assignedBy to the issue list issues params
func (o *IssueListIssuesParams) SetAssignedBy(assignedBy *string) {
	o.AssignedBy = assignedBy
}

// WithBefore adds the before to the issue list issues params
func (o *IssueListIssuesParams) WithBefore(before *strfmt.DateTime) *IssueListIssuesParams {
	o.SetBefore(before)
	return o
}

// SetBefore adds the before to the issue list issues params
func (o *IssueListIssuesParams) SetBefore(before *strfmt.DateTime) {
	o.Before = before
}

// WithCreatedBy adds the createdBy to the issue list issues params
func (o *IssueListIssuesParams) WithCreatedBy(createdBy *string) *IssueListIssuesParams {
	o.SetCreatedBy(createdBy)
	return o
}

// SetCreatedBy adds the createdBy to the issue list issues params
func (o *IssueListIssuesParams) SetCreatedBy(createdBy *string) {
	o.CreatedBy = createdBy
}

// WithLabels adds the labels to the issue list issues params
func (o *IssueListIssuesParams) WithLabels(labels *string) *IssueListIssuesParams {
	o.SetLabels(labels)
	return o
}

// SetLabels adds the labels to the issue list issues params
func (o *IssueListIssuesParams) SetLabels(labels *string) {
	o.Labels = labels
}

// WithLimit adds the limit to the issue list issues params
func (o *IssueListIssuesParams) WithLimit(limit *int64) *IssueListIssuesParams {
	o.SetLimit(limit)
	return o
}

// SetLimit adds the limit to the issue list issues params
func (o *IssueListIssuesParams) SetLimit(limit *int64) {
	o.Limit = limit
}

// WithMentionedBy adds the mentionedBy to the issue list issues params
func (o *IssueListIssuesParams) WithMentionedBy(mentionedBy *string) *IssueListIssuesParams {
	o.SetMentionedBy(mentionedBy)
	return o
}

// SetMentionedBy adds the mentionedBy to the issue list issues params
func (o *IssueListIssuesParams) SetMentionedBy(mentionedBy *string) {
	o.MentionedBy = mentionedBy
}

// WithMilestones adds the milestones to the issue list issues params
func (o *IssueListIssuesParams) WithMilestones(milestones *string) *IssueListIssuesParams {
	o.SetMilestones(milestones)
	return o
}

// SetMilestones adds the milestones to the issue list issues params
func (o *IssueListIssuesParams) SetMilestones(milestones *string) {
	o.Milestones = milestones
}

// WithOwner adds the owner to the issue list issues params
func (o *IssueListIssuesParams) WithOwner(owner string) *IssueListIssuesParams {
	o.SetOwner(owner)
	return o
}

// SetOwner adds the owner to the issue list issues params
func (o *IssueListIssuesParams) SetOwner(owner string) {
	o.Owner = owner
}

// WithPage adds the page to the issue list issues params
func (o *IssueListIssuesParams) WithPage(page *int64) *IssueListIssuesParams {
	o.SetPage(page)
	return o
}

// SetPage adds the page to the issue list issues params
func (o *IssueListIssuesParams) SetPage(page *int64) {
	o.Page = page
}

// WithQ adds the q to the issue list issues params
func (o *IssueListIssuesParams) WithQ(q *string) *IssueListIssuesParams {
	o.SetQ(q)
	return o
}

// SetQ adds the q to the issue list issues params
func (o *IssueListIssuesParams) SetQ(q *string) {
	o.Q = q
}

// WithRepo adds the repo to the issue list issues params
func (o *IssueListIssuesParams) WithRepo(repo string) *IssueListIssuesParams {
	o.SetRepo(repo)
	return o
}

// SetRepo adds the repo to the issue list issues params
func (o *IssueListIssuesParams) SetRepo(repo string) {
	o.Repo = repo
}

// WithSince adds the since to the issue list issues params
func (o *IssueListIssuesParams) WithSince(since *strfmt.DateTime) *IssueListIssuesParams {
	o.SetSince(since)
	return o
}

// SetSince adds the since to the issue list issues params
func (o *IssueListIssuesParams) SetSince(since *strfmt.DateTime) {
	o.Since = since
}

// WithState adds the state to the issue list issues params
func (o *IssueListIssuesParams) WithState(state *string) *IssueListIssuesParams {
	o.SetState(state)
	return o
}

// SetState adds the state to the issue list issues params
func (o *IssueListIssuesParams) SetState(state *string) {
	o.State = state
}

// WithType adds the typeVar to the issue list issues params
func (o *IssueListIssuesParams) WithType(typeVar *string) *IssueListIssuesParams {
	o.SetType(typeVar)
	return o
}

// SetType adds the type to the issue list issues params
func (o *IssueListIssuesParams) SetType(typeVar *string) {
	o.Type = typeVar
}

// WriteToRequest writes these params to a swagger request
func (o *IssueListIssuesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {

	if err := r.SetTimeout(o.timeout); err != nil {
		return err
	}
	var res []error

	if o.AssignedBy != nil {

		// query param assigned_by
		var qrAssignedBy string

		if o.AssignedBy != nil {
			qrAssignedBy = *o.AssignedBy
		}
		qAssignedBy := qrAssignedBy
		if qAssignedBy != "" {

			if err := r.SetQueryParam("assigned_by", qAssignedBy); err != nil {
				return err
			}
		}
	}

	if o.Before != nil {

		// query param before
		var qrBefore strfmt.DateTime

		if o.Before != nil {
			qrBefore = *o.Before
		}
		qBefore := qrBefore.String()
		if qBefore != "" {

			if err := r.SetQueryParam("before", qBefore); err != nil {
				return err
			}
		}
	}

	if o.CreatedBy != nil {

		// query param created_by
		var qrCreatedBy string

		if o.CreatedBy != nil {
			qrCreatedBy = *o.CreatedBy
		}
		qCreatedBy := qrCreatedBy
		if qCreatedBy != "" {

			if err := r.SetQueryParam("created_by", qCreatedBy); err != nil {
				return err
			}
		}
	}

	if o.Labels != nil {

		// query param labels
		var qrLabels string

		if o.Labels != nil {
			qrLabels = *o.Labels
		}
		qLabels := qrLabels
		if qLabels != "" {

			if err := r.SetQueryParam("labels", qLabels); err != nil {
				return err
			}
		}
	}

	if o.Limit != nil {

		// query param limit
		var qrLimit int64

		if o.Limit != nil {
			qrLimit = *o.Limit
		}
		qLimit := swag.FormatInt64(qrLimit)
		if qLimit != "" {

			if err := r.SetQueryParam("limit", qLimit); err != nil {
				return err
			}
		}
	}

	if o.MentionedBy != nil {

		// query param mentioned_by
		var qrMentionedBy string

		if o.MentionedBy != nil {
			qrMentionedBy = *o.MentionedBy
		}
		qMentionedBy := qrMentionedBy
		if qMentionedBy != "" {

			if err := r.SetQueryParam("mentioned_by", qMentionedBy); err != nil {
				return err
			}
		}
	}

	if o.Milestones != nil {

		// query param milestones
		var qrMilestones string

		if o.Milestones != nil {
			qrMilestones = *o.Milestones
		}
		qMilestones := qrMilestones
		if qMilestones != "" {

			if err := r.SetQueryParam("milestones", qMilestones); err != nil {
				return err
			}
		}
	}

	// path param owner
	if err := r.SetPathParam("owner", o.Owner); err != nil {
		return err
	}

	if o.Page != nil {

		// query param page
		var qrPage int64

		if o.Page != nil {
			qrPage = *o.Page
		}
		qPage := swag.FormatInt64(qrPage)
		if qPage != "" {

			if err := r.SetQueryParam("page", qPage); err != nil {
				return err
			}
		}
	}

	if o.Q != nil {

		// query param q
		var qrQ string

		if o.Q != nil {
			qrQ = *o.Q
		}
		qQ := qrQ
		if qQ != "" {

			if err := r.SetQueryParam("q", qQ); err != nil {
				return err
			}
		}
	}

	// path param repo
	if err := r.SetPathParam("repo", o.Repo); err != nil {
		return err
	}

	if o.Since != nil {

		// query param since
		var qrSince strfmt.DateTime

		if o.Since != nil {
			qrSince = *o.Since
		}
		qSince := qrSince.String()
		if qSince != "" {

			if err := r.SetQueryParam("since", qSince); err != nil {
				return err
			}
		}
	}

	if o.State != nil {

		// query param state
		var qrState string

		if o.State != nil {
			qrState = *o.State
		}
		qState := qrState
		if qState != "" {

			if err := r.SetQueryParam("state", qState); err != nil {
				return err
			}
		}
	}

	if o.Type != nil {

		// query param type
		var qrType string

		if o.Type != nil {
			qrType = *o.Type
		}
		qType := qrType
		if qType != "" {

			if err := r.SetQueryParam("type", qType); err != nil {
				return err
			}
		}
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
