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

package policy

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

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

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

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

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

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

	for the list rules operation.

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

	/* Page.

	   The current page of the pagination

	   Format: int32
	*/
	Page *int32

	/* PolicyID.

	   The Policy Id to which these Rules belong.
	*/
	PolicyID string

	/* Query.

	   The search query
	*/
	Query *string

	/* Size.

	   The page size of the pagination

	   Format: int32
	*/
	Size *int32

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

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

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

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

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

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

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

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

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

// WithPage adds the page to the list rules params
func (o *ListRulesParams) WithPage(page *int32) *ListRulesParams {
	o.SetPage(page)
	return o
}

// SetPage adds the page to the list rules params
func (o *ListRulesParams) SetPage(page *int32) {
	o.Page = page
}

// WithPolicyID adds the policyID to the list rules params
func (o *ListRulesParams) WithPolicyID(policyID string) *ListRulesParams {
	o.SetPolicyID(policyID)
	return o
}

// SetPolicyID adds the policyId to the list rules params
func (o *ListRulesParams) SetPolicyID(policyID string) {
	o.PolicyID = policyID
}

// WithQuery adds the query to the list rules params
func (o *ListRulesParams) WithQuery(query *string) *ListRulesParams {
	o.SetQuery(query)
	return o
}

// SetQuery adds the query to the list rules params
func (o *ListRulesParams) SetQuery(query *string) {
	o.Query = query
}

// WithSize adds the size to the list rules params
func (o *ListRulesParams) WithSize(size *int32) *ListRulesParams {
	o.SetSize(size)
	return o
}

// SetSize adds the size to the list rules params
func (o *ListRulesParams) SetSize(size *int32) {
	o.Size = size
}

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

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

	if o.Page != nil {

		// query param page
		var qrPage int32

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

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

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

	if o.Query != nil {

		// query param query
		var qrQuery string

		if o.Query != nil {
			qrQuery = *o.Query
		}
		qQuery := qrQuery
		if qQuery != "" {

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

	if o.Size != nil {

		// query param size
		var qrSize int32

		if o.Size != nil {
			qrSize = *o.Size
		}
		qSize := swag.FormatInt32(qrSize)
		if qSize != "" {

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

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