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

package operations

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

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

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

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

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

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

	for the get apitokens operation.

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

	/* Description.

	   Description
	*/
	Description *string

	/* Limit.

	   Max number of records
	*/
	Limit *int64

	/* Offset.

	   Records offset
	*/
	Offset *int64

	/* Role.

	   Role
	*/
	Role *string

	/* Token.

	   API token
	*/
	Token *string

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

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

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

// WithTimeout adds the timeout to the get apitokens params
func (o *GetApitokensParams) WithTimeout(timeout time.Duration) *GetApitokensParams {
	o.SetTimeout(timeout)
	return o
}

// SetTimeout adds the timeout to the get apitokens params
func (o *GetApitokensParams) SetTimeout(timeout time.Duration) {
	o.timeout = timeout
}

// WithContext adds the context to the get apitokens params
func (o *GetApitokensParams) WithContext(ctx context.Context) *GetApitokensParams {
	o.SetContext(ctx)
	return o
}

// SetContext adds the context to the get apitokens params
func (o *GetApitokensParams) SetContext(ctx context.Context) {
	o.Context = ctx
}

// WithHTTPClient adds the HTTPClient to the get apitokens params
func (o *GetApitokensParams) WithHTTPClient(client *http.Client) *GetApitokensParams {
	o.SetHTTPClient(client)
	return o
}

// SetHTTPClient adds the HTTPClient to the get apitokens params
func (o *GetApitokensParams) SetHTTPClient(client *http.Client) {
	o.HTTPClient = client
}

// WithDescription adds the description to the get apitokens params
func (o *GetApitokensParams) WithDescription(description *string) *GetApitokensParams {
	o.SetDescription(description)
	return o
}

// SetDescription adds the description to the get apitokens params
func (o *GetApitokensParams) SetDescription(description *string) {
	o.Description = description
}

// WithLimit adds the limit to the get apitokens params
func (o *GetApitokensParams) WithLimit(limit *int64) *GetApitokensParams {
	o.SetLimit(limit)
	return o
}

// SetLimit adds the limit to the get apitokens params
func (o *GetApitokensParams) SetLimit(limit *int64) {
	o.Limit = limit
}

// WithOffset adds the offset to the get apitokens params
func (o *GetApitokensParams) WithOffset(offset *int64) *GetApitokensParams {
	o.SetOffset(offset)
	return o
}

// SetOffset adds the offset to the get apitokens params
func (o *GetApitokensParams) SetOffset(offset *int64) {
	o.Offset = offset
}

// WithRole adds the role to the get apitokens params
func (o *GetApitokensParams) WithRole(role *string) *GetApitokensParams {
	o.SetRole(role)
	return o
}

// SetRole adds the role to the get apitokens params
func (o *GetApitokensParams) SetRole(role *string) {
	o.Role = role
}

// WithToken adds the token to the get apitokens params
func (o *GetApitokensParams) WithToken(token *string) *GetApitokensParams {
	o.SetToken(token)
	return o
}

// SetToken adds the token to the get apitokens params
func (o *GetApitokensParams) SetToken(token *string) {
	o.Token = token
}

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

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

	if o.Description != nil {

		// query param description
		var qrDescription string

		if o.Description != nil {
			qrDescription = *o.Description
		}
		qDescription := qrDescription
		if qDescription != "" {

			if err := r.SetQueryParam("description", qDescription); 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.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.Role != nil {

		// query param role
		var qrRole string

		if o.Role != nil {
			qrRole = *o.Role
		}
		qRole := qrRole
		if qRole != "" {

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

	if o.Token != nil {

		// query param token
		var qrToken string

		if o.Token != nil {
			qrToken = *o.Token
		}
		qToken := qrToken
		if qToken != "" {

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

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