github.com/circl-dev/go-swagger@v0.31.0/examples/task-tracker/client/tasks/list_tasks_parameters.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package tasks
     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  // NewListTasksParams creates a new ListTasksParams 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 NewListTasksParams() *ListTasksParams {
    27  	return &ListTasksParams{
    28  		timeout: cr.DefaultTimeout,
    29  	}
    30  }
    31  
    32  // NewListTasksParamsWithTimeout creates a new ListTasksParams object
    33  // with the ability to set a timeout on a request.
    34  func NewListTasksParamsWithTimeout(timeout time.Duration) *ListTasksParams {
    35  	return &ListTasksParams{
    36  		timeout: timeout,
    37  	}
    38  }
    39  
    40  // NewListTasksParamsWithContext creates a new ListTasksParams object
    41  // with the ability to set a context for a request.
    42  func NewListTasksParamsWithContext(ctx context.Context) *ListTasksParams {
    43  	return &ListTasksParams{
    44  		Context: ctx,
    45  	}
    46  }
    47  
    48  // NewListTasksParamsWithHTTPClient creates a new ListTasksParams object
    49  // with the ability to set a custom HTTPClient for a request.
    50  func NewListTasksParamsWithHTTPClient(client *http.Client) *ListTasksParams {
    51  	return &ListTasksParams{
    52  		HTTPClient: client,
    53  	}
    54  }
    55  
    56  /* ListTasksParams contains all the parameters to send to the API endpoint
    57     for the list tasks operation.
    58  
    59     Typically these are written to a http.Request.
    60  */
    61  type ListTasksParams struct {
    62  
    63  	/* PageSize.
    64  
    65  	   Amount of items to return in a single page
    66  
    67  	   Format: int32
    68  	   Default: 20
    69  	*/
    70  	PageSize *int32
    71  
    72  	/* SinceID.
    73  
    74  	   The last id that was seen.
    75  
    76  	   Format: int64
    77  	*/
    78  	SinceID *int64
    79  
    80  	/* Status.
    81  
    82  	   the status to filter by
    83  	*/
    84  	Status []string
    85  
    86  	/* Tags.
    87  
    88  	   the tags to filter by
    89  	*/
    90  	Tags []string
    91  
    92  	timeout    time.Duration
    93  	Context    context.Context
    94  	HTTPClient *http.Client
    95  }
    96  
    97  // WithDefaults hydrates default values in the list tasks params (not the query body).
    98  //
    99  // All values with no default are reset to their zero value.
   100  func (o *ListTasksParams) WithDefaults() *ListTasksParams {
   101  	o.SetDefaults()
   102  	return o
   103  }
   104  
   105  // SetDefaults hydrates default values in the list tasks params (not the query body).
   106  //
   107  // All values with no default are reset to their zero value.
   108  func (o *ListTasksParams) SetDefaults() {
   109  	var (
   110  		pageSizeDefault = int32(20)
   111  	)
   112  
   113  	val := ListTasksParams{
   114  		PageSize: &pageSizeDefault,
   115  	}
   116  
   117  	val.timeout = o.timeout
   118  	val.Context = o.Context
   119  	val.HTTPClient = o.HTTPClient
   120  	*o = val
   121  }
   122  
   123  // WithTimeout adds the timeout to the list tasks params
   124  func (o *ListTasksParams) WithTimeout(timeout time.Duration) *ListTasksParams {
   125  	o.SetTimeout(timeout)
   126  	return o
   127  }
   128  
   129  // SetTimeout adds the timeout to the list tasks params
   130  func (o *ListTasksParams) SetTimeout(timeout time.Duration) {
   131  	o.timeout = timeout
   132  }
   133  
   134  // WithContext adds the context to the list tasks params
   135  func (o *ListTasksParams) WithContext(ctx context.Context) *ListTasksParams {
   136  	o.SetContext(ctx)
   137  	return o
   138  }
   139  
   140  // SetContext adds the context to the list tasks params
   141  func (o *ListTasksParams) SetContext(ctx context.Context) {
   142  	o.Context = ctx
   143  }
   144  
   145  // WithHTTPClient adds the HTTPClient to the list tasks params
   146  func (o *ListTasksParams) WithHTTPClient(client *http.Client) *ListTasksParams {
   147  	o.SetHTTPClient(client)
   148  	return o
   149  }
   150  
   151  // SetHTTPClient adds the HTTPClient to the list tasks params
   152  func (o *ListTasksParams) SetHTTPClient(client *http.Client) {
   153  	o.HTTPClient = client
   154  }
   155  
   156  // WithPageSize adds the pageSize to the list tasks params
   157  func (o *ListTasksParams) WithPageSize(pageSize *int32) *ListTasksParams {
   158  	o.SetPageSize(pageSize)
   159  	return o
   160  }
   161  
   162  // SetPageSize adds the pageSize to the list tasks params
   163  func (o *ListTasksParams) SetPageSize(pageSize *int32) {
   164  	o.PageSize = pageSize
   165  }
   166  
   167  // WithSinceID adds the sinceID to the list tasks params
   168  func (o *ListTasksParams) WithSinceID(sinceID *int64) *ListTasksParams {
   169  	o.SetSinceID(sinceID)
   170  	return o
   171  }
   172  
   173  // SetSinceID adds the sinceId to the list tasks params
   174  func (o *ListTasksParams) SetSinceID(sinceID *int64) {
   175  	o.SinceID = sinceID
   176  }
   177  
   178  // WithStatus adds the status to the list tasks params
   179  func (o *ListTasksParams) WithStatus(status []string) *ListTasksParams {
   180  	o.SetStatus(status)
   181  	return o
   182  }
   183  
   184  // SetStatus adds the status to the list tasks params
   185  func (o *ListTasksParams) SetStatus(status []string) {
   186  	o.Status = status
   187  }
   188  
   189  // WithTags adds the tags to the list tasks params
   190  func (o *ListTasksParams) WithTags(tags []string) *ListTasksParams {
   191  	o.SetTags(tags)
   192  	return o
   193  }
   194  
   195  // SetTags adds the tags to the list tasks params
   196  func (o *ListTasksParams) SetTags(tags []string) {
   197  	o.Tags = tags
   198  }
   199  
   200  // WriteToRequest writes these params to a swagger request
   201  func (o *ListTasksParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   202  
   203  	if err := r.SetTimeout(o.timeout); err != nil {
   204  		return err
   205  	}
   206  	var res []error
   207  
   208  	if o.PageSize != nil {
   209  
   210  		// query param pageSize
   211  		var qrPageSize int32
   212  
   213  		if o.PageSize != nil {
   214  			qrPageSize = *o.PageSize
   215  		}
   216  		qPageSize := swag.FormatInt32(qrPageSize)
   217  		if qPageSize != "" {
   218  
   219  			if err := r.SetQueryParam("pageSize", qPageSize); err != nil {
   220  				return err
   221  			}
   222  		}
   223  	}
   224  
   225  	if o.SinceID != nil {
   226  
   227  		// query param sinceId
   228  		var qrSinceID int64
   229  
   230  		if o.SinceID != nil {
   231  			qrSinceID = *o.SinceID
   232  		}
   233  		qSinceID := swag.FormatInt64(qrSinceID)
   234  		if qSinceID != "" {
   235  
   236  			if err := r.SetQueryParam("sinceId", qSinceID); err != nil {
   237  				return err
   238  			}
   239  		}
   240  	}
   241  
   242  	if o.Status != nil {
   243  
   244  		// binding items for status
   245  		joinedStatus := o.bindParamStatus(reg)
   246  
   247  		// query array param status
   248  		if err := r.SetQueryParam("status", joinedStatus...); err != nil {
   249  			return err
   250  		}
   251  	}
   252  
   253  	if o.Tags != nil {
   254  
   255  		// binding items for tags
   256  		joinedTags := o.bindParamTags(reg)
   257  
   258  		// query array param tags
   259  		if err := r.SetQueryParam("tags", joinedTags...); err != nil {
   260  			return err
   261  		}
   262  	}
   263  
   264  	if len(res) > 0 {
   265  		return errors.CompositeValidationError(res...)
   266  	}
   267  	return nil
   268  }
   269  
   270  // bindParamListTasks binds the parameter status
   271  func (o *ListTasksParams) bindParamStatus(formats strfmt.Registry) []string {
   272  	statusIR := o.Status
   273  
   274  	var statusIC []string
   275  	for _, statusIIR := range statusIR { // explode []string
   276  
   277  		statusIIV := statusIIR // string as string
   278  		statusIC = append(statusIC, statusIIV)
   279  	}
   280  
   281  	// items.CollectionFormat: "pipes"
   282  	statusIS := swag.JoinByFormat(statusIC, "pipes")
   283  
   284  	return statusIS
   285  }
   286  
   287  // bindParamListTasks binds the parameter tags
   288  func (o *ListTasksParams) bindParamTags(formats strfmt.Registry) []string {
   289  	tagsIR := o.Tags
   290  
   291  	var tagsIC []string
   292  	for _, tagsIIR := range tagsIR { // explode []string
   293  
   294  		tagsIIV := tagsIIR // string as string
   295  		tagsIC = append(tagsIC, tagsIIV)
   296  	}
   297  
   298  	// items.CollectionFormat: ""
   299  	tagsIS := swag.JoinByFormat(tagsIC, "")
   300  
   301  	return tagsIS
   302  }