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

package tenant_service

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

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

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

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

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

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

	for the tenant service list operation.

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

	/* Limit.

	     Max number of tenants to return in the result-set.
	If not set, it will be treated as 0, and the response will only return the total_count.

	     Format: int64
	*/
	Limit *int64

	/* Offset.

	   Offset in the result-set (for pagination).

	   Format: int64
	*/
	Offset *int64

	/* Search.

	   If set, the given string will be used to search on name.
	*/
	Search *string

	/* UserID.

	     If set, filters the result set to the tenants of the user.
	Only global API keys are able to filter by this field.
	*/
	UserID *string

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

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

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

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

// SetTimeout adds the timeout to the tenant service list params
func (o *TenantServiceListParams) SetTimeout(timeout time.Duration) {
	o.timeout = timeout
}

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

// SetContext adds the context to the tenant service list params
func (o *TenantServiceListParams) SetContext(ctx context.Context) {
	o.Context = ctx
}

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

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

// WithLimit adds the limit to the tenant service list params
func (o *TenantServiceListParams) WithLimit(limit *int64) *TenantServiceListParams {
	o.SetLimit(limit)
	return o
}

// SetLimit adds the limit to the tenant service list params
func (o *TenantServiceListParams) SetLimit(limit *int64) {
	o.Limit = limit
}

// WithOffset adds the offset to the tenant service list params
func (o *TenantServiceListParams) WithOffset(offset *int64) *TenantServiceListParams {
	o.SetOffset(offset)
	return o
}

// SetOffset adds the offset to the tenant service list params
func (o *TenantServiceListParams) SetOffset(offset *int64) {
	o.Offset = offset
}

// WithSearch adds the search to the tenant service list params
func (o *TenantServiceListParams) WithSearch(search *string) *TenantServiceListParams {
	o.SetSearch(search)
	return o
}

// SetSearch adds the search to the tenant service list params
func (o *TenantServiceListParams) SetSearch(search *string) {
	o.Search = search
}

// WithUserID adds the userID to the tenant service list params
func (o *TenantServiceListParams) WithUserID(userID *string) *TenantServiceListParams {
	o.SetUserID(userID)
	return o
}

// SetUserID adds the userId to the tenant service list params
func (o *TenantServiceListParams) SetUserID(userID *string) {
	o.UserID = userID
}

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

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

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

		// query param offset
		var qrOffset int64

		if o.Offset != nil {
			qrOffset = *o.Offset
		}
		qOffset := swag.FormatInt64(qrOffset)
		if qOffset != "" {

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

	if o.Search != nil {

		// query param search
		var qrSearch string

		if o.Search != nil {
			qrSearch = *o.Search
		}
		qSearch := qrSearch
		if qSearch != "" {

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

	if o.UserID != nil {

		// query param userId
		var qrUserID string

		if o.UserID != nil {
			qrUserID = *o.UserID
		}
		qUserID := qrUserID
		if qUserID != "" {

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

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