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

package repository

// 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"
)

// NewRepoListReleasesParams creates a new RepoListReleasesParams 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 NewRepoListReleasesParams() *RepoListReleasesParams {
	return &RepoListReleasesParams{
		timeout: cr.DefaultTimeout,
	}
}

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

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

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

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

	for the repo list releases operation.

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

	/* Draft.

	   filter (exclude / include) drafts, if you dont have repo write access none will show
	*/
	Draft *bool

	/* Limit.

	   page size of results
	*/
	Limit *int64

	/* Owner.

	   owner of the repo
	*/
	Owner string

	/* Page.

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

	/* PreRelease.

	   filter (exclude / include) pre-releases
	*/
	PreRelease *bool

	/* Repo.

	   name of the repo
	*/
	Repo string

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

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

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

// WithTimeout adds the timeout to the repo list releases params
func (o *RepoListReleasesParams) WithTimeout(timeout time.Duration) *RepoListReleasesParams {
	o.SetTimeout(timeout)
	return o
}

// SetTimeout adds the timeout to the repo list releases params
func (o *RepoListReleasesParams) SetTimeout(timeout time.Duration) {
	o.timeout = timeout
}

// WithContext adds the context to the repo list releases params
func (o *RepoListReleasesParams) WithContext(ctx context.Context) *RepoListReleasesParams {
	o.SetContext(ctx)
	return o
}

// SetContext adds the context to the repo list releases params
func (o *RepoListReleasesParams) SetContext(ctx context.Context) {
	o.Context = ctx
}

// WithHTTPClient adds the HTTPClient to the repo list releases params
func (o *RepoListReleasesParams) WithHTTPClient(client *http.Client) *RepoListReleasesParams {
	o.SetHTTPClient(client)
	return o
}

// SetHTTPClient adds the HTTPClient to the repo list releases params
func (o *RepoListReleasesParams) SetHTTPClient(client *http.Client) {
	o.HTTPClient = client
}

// WithDraft adds the draft to the repo list releases params
func (o *RepoListReleasesParams) WithDraft(draft *bool) *RepoListReleasesParams {
	o.SetDraft(draft)
	return o
}

// SetDraft adds the draft to the repo list releases params
func (o *RepoListReleasesParams) SetDraft(draft *bool) {
	o.Draft = draft
}

// WithLimit adds the limit to the repo list releases params
func (o *RepoListReleasesParams) WithLimit(limit *int64) *RepoListReleasesParams {
	o.SetLimit(limit)
	return o
}

// SetLimit adds the limit to the repo list releases params
func (o *RepoListReleasesParams) SetLimit(limit *int64) {
	o.Limit = limit
}

// WithOwner adds the owner to the repo list releases params
func (o *RepoListReleasesParams) WithOwner(owner string) *RepoListReleasesParams {
	o.SetOwner(owner)
	return o
}

// SetOwner adds the owner to the repo list releases params
func (o *RepoListReleasesParams) SetOwner(owner string) {
	o.Owner = owner
}

// WithPage adds the page to the repo list releases params
func (o *RepoListReleasesParams) WithPage(page *int64) *RepoListReleasesParams {
	o.SetPage(page)
	return o
}

// SetPage adds the page to the repo list releases params
func (o *RepoListReleasesParams) SetPage(page *int64) {
	o.Page = page
}

// WithPreRelease adds the preRelease to the repo list releases params
func (o *RepoListReleasesParams) WithPreRelease(preRelease *bool) *RepoListReleasesParams {
	o.SetPreRelease(preRelease)
	return o
}

// SetPreRelease adds the preRelease to the repo list releases params
func (o *RepoListReleasesParams) SetPreRelease(preRelease *bool) {
	o.PreRelease = preRelease
}

// WithRepo adds the repo to the repo list releases params
func (o *RepoListReleasesParams) WithRepo(repo string) *RepoListReleasesParams {
	o.SetRepo(repo)
	return o
}

// SetRepo adds the repo to the repo list releases params
func (o *RepoListReleasesParams) SetRepo(repo string) {
	o.Repo = repo
}

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

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

	if o.Draft != nil {

		// query param draft
		var qrDraft bool

		if o.Draft != nil {
			qrDraft = *o.Draft
		}
		qDraft := swag.FormatBool(qrDraft)
		if qDraft != "" {

			if err := r.SetQueryParam("draft", qDraft); 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
			}
		}
	}

	// 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.PreRelease != nil {

		// query param pre-release
		var qrPreRelease bool

		if o.PreRelease != nil {
			qrPreRelease = *o.PreRelease
		}
		qPreRelease := swag.FormatBool(qrPreRelease)
		if qPreRelease != "" {

			if err := r.SetQueryParam("pre-release", qPreRelease); err != nil {
				return err
			}
		}
	}

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

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