github.com/circl-dev/go-swagger@v0.31.0/examples/cli/client/todos/find_todos_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  // NewFindTodosParams creates a new FindTodosParams object,
    21  // with the default timeout for this client.
    22  //
    23  // Default values are not hydrated, since defaults are normally applied by the API server side.
    24  //
    25  // To enforce default values in parameter, use SetDefaults or WithDefaults.
    26  func NewFindTodosParams() *FindTodosParams {
    27  	return &FindTodosParams{
    28  		timeout: cr.DefaultTimeout,
    29  	}
    30  }
    31  
    32  // NewFindTodosParamsWithTimeout creates a new FindTodosParams object
    33  // with the ability to set a timeout on a request.
    34  func NewFindTodosParamsWithTimeout(timeout time.Duration) *FindTodosParams {
    35  	return &FindTodosParams{
    36  		timeout: timeout,
    37  	}
    38  }
    39  
    40  // NewFindTodosParamsWithContext creates a new FindTodosParams object
    41  // with the ability to set a context for a request.
    42  func NewFindTodosParamsWithContext(ctx context.Context) *FindTodosParams {
    43  	return &FindTodosParams{
    44  		Context: ctx,
    45  	}
    46  }
    47  
    48  // NewFindTodosParamsWithHTTPClient creates a new FindTodosParams object
    49  // with the ability to set a custom HTTPClient for a request.
    50  func NewFindTodosParamsWithHTTPClient(client *http.Client) *FindTodosParams {
    51  	return &FindTodosParams{
    52  		HTTPClient: client,
    53  	}
    54  }
    55  
    56  /* FindTodosParams contains all the parameters to send to the API endpoint
    57     for the find todos operation.
    58  
    59     Typically these are written to a http.Request.
    60  */
    61  type FindTodosParams struct {
    62  
    63  	// Limit.
    64  	//
    65  	// Format: int32
    66  	// Default: 20
    67  	Limit *int32
    68  
    69  	// Since.
    70  	//
    71  	// Format: int64
    72  	Since *int64
    73  
    74  	timeout    time.Duration
    75  	Context    context.Context
    76  	HTTPClient *http.Client
    77  }
    78  
    79  // WithDefaults hydrates default values in the find todos params (not the query body).
    80  //
    81  // All values with no default are reset to their zero value.
    82  func (o *FindTodosParams) WithDefaults() *FindTodosParams {
    83  	o.SetDefaults()
    84  	return o
    85  }
    86  
    87  // SetDefaults hydrates default values in the find todos params (not the query body).
    88  //
    89  // All values with no default are reset to their zero value.
    90  func (o *FindTodosParams) SetDefaults() {
    91  	var (
    92  		limitDefault = int32(20)
    93  	)
    94  
    95  	val := FindTodosParams{
    96  		Limit: &limitDefault,
    97  	}
    98  
    99  	val.timeout = o.timeout
   100  	val.Context = o.Context
   101  	val.HTTPClient = o.HTTPClient
   102  	*o = val
   103  }
   104  
   105  // WithTimeout adds the timeout to the find todos params
   106  func (o *FindTodosParams) WithTimeout(timeout time.Duration) *FindTodosParams {
   107  	o.SetTimeout(timeout)
   108  	return o
   109  }
   110  
   111  // SetTimeout adds the timeout to the find todos params
   112  func (o *FindTodosParams) SetTimeout(timeout time.Duration) {
   113  	o.timeout = timeout
   114  }
   115  
   116  // WithContext adds the context to the find todos params
   117  func (o *FindTodosParams) WithContext(ctx context.Context) *FindTodosParams {
   118  	o.SetContext(ctx)
   119  	return o
   120  }
   121  
   122  // SetContext adds the context to the find todos params
   123  func (o *FindTodosParams) SetContext(ctx context.Context) {
   124  	o.Context = ctx
   125  }
   126  
   127  // WithHTTPClient adds the HTTPClient to the find todos params
   128  func (o *FindTodosParams) WithHTTPClient(client *http.Client) *FindTodosParams {
   129  	o.SetHTTPClient(client)
   130  	return o
   131  }
   132  
   133  // SetHTTPClient adds the HTTPClient to the find todos params
   134  func (o *FindTodosParams) SetHTTPClient(client *http.Client) {
   135  	o.HTTPClient = client
   136  }
   137  
   138  // WithLimit adds the limit to the find todos params
   139  func (o *FindTodosParams) WithLimit(limit *int32) *FindTodosParams {
   140  	o.SetLimit(limit)
   141  	return o
   142  }
   143  
   144  // SetLimit adds the limit to the find todos params
   145  func (o *FindTodosParams) SetLimit(limit *int32) {
   146  	o.Limit = limit
   147  }
   148  
   149  // WithSince adds the since to the find todos params
   150  func (o *FindTodosParams) WithSince(since *int64) *FindTodosParams {
   151  	o.SetSince(since)
   152  	return o
   153  }
   154  
   155  // SetSince adds the since to the find todos params
   156  func (o *FindTodosParams) SetSince(since *int64) {
   157  	o.Since = since
   158  }
   159  
   160  // WriteToRequest writes these params to a swagger request
   161  func (o *FindTodosParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   162  
   163  	if err := r.SetTimeout(o.timeout); err != nil {
   164  		return err
   165  	}
   166  	var res []error
   167  
   168  	if o.Limit != nil {
   169  
   170  		// query param limit
   171  		var qrLimit int32
   172  
   173  		if o.Limit != nil {
   174  			qrLimit = *o.Limit
   175  		}
   176  		qLimit := swag.FormatInt32(qrLimit)
   177  		if qLimit != "" {
   178  
   179  			if err := r.SetQueryParam("limit", qLimit); err != nil {
   180  				return err
   181  			}
   182  		}
   183  	}
   184  
   185  	if o.Since != nil {
   186  
   187  		// query param since
   188  		var qrSince int64
   189  
   190  		if o.Since != nil {
   191  			qrSince = *o.Since
   192  		}
   193  		qSince := swag.FormatInt64(qrSince)
   194  		if qSince != "" {
   195  
   196  			if err := r.SetQueryParam("since", qSince); err != nil {
   197  				return err
   198  			}
   199  		}
   200  	}
   201  
   202  	if len(res) > 0 {
   203  		return errors.CompositeValidationError(res...)
   204  	}
   205  	return nil
   206  }