github.com/circl-dev/go-swagger@v0.31.0/examples/todo-list-strict/client/todos/find_parameters.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package todos
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	"context"
    10  	"net/http"
    11  	"time"
    12  
    13  	"github.com/go-openapi/errors"
    14  	"github.com/go-openapi/strfmt"
    15  	"github.com/go-openapi/swag"
    16  	"github.com/circl-dev/runtime"
    17  	cr "github.com/circl-dev/runtime/client"
    18  )
    19  
    20  // NewFindParams creates a new FindParams object
    21  // with the default values initialized.
    22  func NewFindParams() *FindParams {
    23  	var ()
    24  	return &FindParams{
    25  
    26  		timeout: cr.DefaultTimeout,
    27  	}
    28  }
    29  
    30  // NewFindParamsWithTimeout creates a new FindParams object
    31  // with the default values initialized, and the ability to set a timeout on a request
    32  func NewFindParamsWithTimeout(timeout time.Duration) *FindParams {
    33  	var ()
    34  	return &FindParams{
    35  
    36  		timeout: timeout,
    37  	}
    38  }
    39  
    40  // NewFindParamsWithContext creates a new FindParams object
    41  // with the default values initialized, and the ability to set a context for a request
    42  func NewFindParamsWithContext(ctx context.Context) *FindParams {
    43  	var ()
    44  	return &FindParams{
    45  
    46  		Context: ctx,
    47  	}
    48  }
    49  
    50  // NewFindParamsWithHTTPClient creates a new FindParams object
    51  // with the default values initialized, and the ability to set a custom HTTPClient for a request
    52  func NewFindParamsWithHTTPClient(client *http.Client) *FindParams {
    53  	var ()
    54  	return &FindParams{
    55  		HTTPClient: client,
    56  	}
    57  }
    58  
    59  /*FindParams contains all the parameters to send to the API endpoint
    60  for the find operation typically these are written to a http.Request
    61  */
    62  type FindParams struct {
    63  
    64  	/*XRateLimit*/
    65  	XRateLimit int32
    66  	/*Limit*/
    67  	Limit int32
    68  	/*Tags*/
    69  	Tags []int32
    70  
    71  	timeout    time.Duration
    72  	Context    context.Context
    73  	HTTPClient *http.Client
    74  }
    75  
    76  // WithTimeout adds the timeout to the find params
    77  func (o *FindParams) WithTimeout(timeout time.Duration) *FindParams {
    78  	o.SetTimeout(timeout)
    79  	return o
    80  }
    81  
    82  // SetTimeout adds the timeout to the find params
    83  func (o *FindParams) SetTimeout(timeout time.Duration) {
    84  	o.timeout = timeout
    85  }
    86  
    87  // WithContext adds the context to the find params
    88  func (o *FindParams) WithContext(ctx context.Context) *FindParams {
    89  	o.SetContext(ctx)
    90  	return o
    91  }
    92  
    93  // SetContext adds the context to the find params
    94  func (o *FindParams) SetContext(ctx context.Context) {
    95  	o.Context = ctx
    96  }
    97  
    98  // WithHTTPClient adds the HTTPClient to the find params
    99  func (o *FindParams) WithHTTPClient(client *http.Client) *FindParams {
   100  	o.SetHTTPClient(client)
   101  	return o
   102  }
   103  
   104  // SetHTTPClient adds the HTTPClient to the find params
   105  func (o *FindParams) SetHTTPClient(client *http.Client) {
   106  	o.HTTPClient = client
   107  }
   108  
   109  // WithXRateLimit adds the xRateLimit to the find params
   110  func (o *FindParams) WithXRateLimit(xRateLimit int32) *FindParams {
   111  	o.SetXRateLimit(xRateLimit)
   112  	return o
   113  }
   114  
   115  // SetXRateLimit adds the xRateLimit to the find params
   116  func (o *FindParams) SetXRateLimit(xRateLimit int32) {
   117  	o.XRateLimit = xRateLimit
   118  }
   119  
   120  // WithLimit adds the limit to the find params
   121  func (o *FindParams) WithLimit(limit int32) *FindParams {
   122  	o.SetLimit(limit)
   123  	return o
   124  }
   125  
   126  // SetLimit adds the limit to the find params
   127  func (o *FindParams) SetLimit(limit int32) {
   128  	o.Limit = limit
   129  }
   130  
   131  // WithTags adds the tags to the find params
   132  func (o *FindParams) WithTags(tags []int32) *FindParams {
   133  	o.SetTags(tags)
   134  	return o
   135  }
   136  
   137  // SetTags adds the tags to the find params
   138  func (o *FindParams) SetTags(tags []int32) {
   139  	o.Tags = tags
   140  }
   141  
   142  // WriteToRequest writes these params to a swagger request
   143  func (o *FindParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   144  
   145  	if err := r.SetTimeout(o.timeout); err != nil {
   146  		return err
   147  	}
   148  	var res []error
   149  
   150  	// header param X-Rate-Limit
   151  	if err := r.SetHeaderParam("X-Rate-Limit", swag.FormatInt32(o.XRateLimit)); err != nil {
   152  		return err
   153  	}
   154  
   155  	// form param limit
   156  	frLimit := o.Limit
   157  	fLimit := swag.FormatInt32(frLimit)
   158  	if err := r.SetFormParam("limit", fLimit); err != nil {
   159  		return err
   160  	}
   161  
   162  	var valuesTags []string
   163  	for _, v := range o.Tags {
   164  		valuesTags = append(valuesTags, swag.FormatInt32(v))
   165  	}
   166  
   167  	joinedTags := swag.JoinByFormat(valuesTags, "multi")
   168  	// form array param tags
   169  	if err := r.SetFormParam("tags", joinedTags...); err != nil {
   170  		return err
   171  	}
   172  
   173  	if len(res) > 0 {
   174  		return errors.CompositeValidationError(res...)
   175  	}
   176  	return nil
   177  }