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

package templates

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

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

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

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

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

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

	for the list templates operation.

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

	/* ForgeType.

	   Forge type of the templates.
	*/
	ForgeType *string

	/* OsType.

	   OS type of the templates.
	*/
	OsType *string

	/* PartialName.

	   Partial or full name of the template.
	*/
	PartialName *string

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

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

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

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

// SetTimeout adds the timeout to the list templates params
func (o *ListTemplatesParams) SetTimeout(timeout time.Duration) {
	o.timeout = timeout
}

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

// SetContext adds the context to the list templates params
func (o *ListTemplatesParams) SetContext(ctx context.Context) {
	o.Context = ctx
}

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

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

// WithForgeType adds the forgeType to the list templates params
func (o *ListTemplatesParams) WithForgeType(forgeType *string) *ListTemplatesParams {
	o.SetForgeType(forgeType)
	return o
}

// SetForgeType adds the forgeType to the list templates params
func (o *ListTemplatesParams) SetForgeType(forgeType *string) {
	o.ForgeType = forgeType
}

// WithOsType adds the osType to the list templates params
func (o *ListTemplatesParams) WithOsType(osType *string) *ListTemplatesParams {
	o.SetOsType(osType)
	return o
}

// SetOsType adds the osType to the list templates params
func (o *ListTemplatesParams) SetOsType(osType *string) {
	o.OsType = osType
}

// WithPartialName adds the partialName to the list templates params
func (o *ListTemplatesParams) WithPartialName(partialName *string) *ListTemplatesParams {
	o.SetPartialName(partialName)
	return o
}

// SetPartialName adds the partialName to the list templates params
func (o *ListTemplatesParams) SetPartialName(partialName *string) {
	o.PartialName = partialName
}

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

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

	if o.ForgeType != nil {

		// query param forgeType
		var qrForgeType string

		if o.ForgeType != nil {
			qrForgeType = *o.ForgeType
		}
		qForgeType := qrForgeType
		if qForgeType != "" {

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

	if o.OsType != nil {

		// query param osType
		var qrOsType string

		if o.OsType != nil {
			qrOsType = *o.OsType
		}
		qOsType := qrOsType
		if qOsType != "" {

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

	if o.PartialName != nil {

		// query param partialName
		var qrPartialName string

		if o.PartialName != nil {
			qrPartialName = *o.PartialName
		}
		qPartialName := qrPartialName
		if qPartialName != "" {

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

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