github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/task-tracker/client/tasks/get_task_comments_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/runtime"
    15  	cr "github.com/go-openapi/runtime/client"
    16  	"github.com/go-openapi/strfmt"
    17  	"github.com/go-openapi/swag"
    18  )
    19  
    20  // NewGetTaskCommentsParams creates a new GetTaskCommentsParams 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 NewGetTaskCommentsParams() *GetTaskCommentsParams {
    27  	return &GetTaskCommentsParams{
    28  		timeout: cr.DefaultTimeout,
    29  	}
    30  }
    31  
    32  // NewGetTaskCommentsParamsWithTimeout creates a new GetTaskCommentsParams object
    33  // with the ability to set a timeout on a request.
    34  func NewGetTaskCommentsParamsWithTimeout(timeout time.Duration) *GetTaskCommentsParams {
    35  	return &GetTaskCommentsParams{
    36  		timeout: timeout,
    37  	}
    38  }
    39  
    40  // NewGetTaskCommentsParamsWithContext creates a new GetTaskCommentsParams object
    41  // with the ability to set a context for a request.
    42  func NewGetTaskCommentsParamsWithContext(ctx context.Context) *GetTaskCommentsParams {
    43  	return &GetTaskCommentsParams{
    44  		Context: ctx,
    45  	}
    46  }
    47  
    48  // NewGetTaskCommentsParamsWithHTTPClient creates a new GetTaskCommentsParams object
    49  // with the ability to set a custom HTTPClient for a request.
    50  func NewGetTaskCommentsParamsWithHTTPClient(client *http.Client) *GetTaskCommentsParams {
    51  	return &GetTaskCommentsParams{
    52  		HTTPClient: client,
    53  	}
    54  }
    55  
    56  /*
    57  GetTaskCommentsParams contains all the parameters to send to the API endpoint
    58  
    59  	for the get task comments operation.
    60  
    61  	Typically these are written to a http.Request.
    62  */
    63  type GetTaskCommentsParams struct {
    64  
    65  	/* ID.
    66  
    67  	   The id of the item
    68  
    69  	   Format: int64
    70  	*/
    71  	ID int64
    72  
    73  	/* PageSize.
    74  
    75  	   Amount of items to return in a single page
    76  
    77  	   Format: int32
    78  	   Default: 20
    79  	*/
    80  	PageSize *int32
    81  
    82  	/* Since.
    83  
    84  	   The created time of the oldest seen comment
    85  
    86  	   Format: date-time
    87  	*/
    88  	Since *strfmt.DateTime
    89  
    90  	timeout    time.Duration
    91  	Context    context.Context
    92  	HTTPClient *http.Client
    93  }
    94  
    95  // WithDefaults hydrates default values in the get task comments params (not the query body).
    96  //
    97  // All values with no default are reset to their zero value.
    98  func (o *GetTaskCommentsParams) WithDefaults() *GetTaskCommentsParams {
    99  	o.SetDefaults()
   100  	return o
   101  }
   102  
   103  // SetDefaults hydrates default values in the get task comments params (not the query body).
   104  //
   105  // All values with no default are reset to their zero value.
   106  func (o *GetTaskCommentsParams) SetDefaults() {
   107  	var (
   108  		pageSizeDefault = int32(20)
   109  	)
   110  
   111  	val := GetTaskCommentsParams{
   112  		PageSize: &pageSizeDefault,
   113  	}
   114  
   115  	val.timeout = o.timeout
   116  	val.Context = o.Context
   117  	val.HTTPClient = o.HTTPClient
   118  	*o = val
   119  }
   120  
   121  // WithTimeout adds the timeout to the get task comments params
   122  func (o *GetTaskCommentsParams) WithTimeout(timeout time.Duration) *GetTaskCommentsParams {
   123  	o.SetTimeout(timeout)
   124  	return o
   125  }
   126  
   127  // SetTimeout adds the timeout to the get task comments params
   128  func (o *GetTaskCommentsParams) SetTimeout(timeout time.Duration) {
   129  	o.timeout = timeout
   130  }
   131  
   132  // WithContext adds the context to the get task comments params
   133  func (o *GetTaskCommentsParams) WithContext(ctx context.Context) *GetTaskCommentsParams {
   134  	o.SetContext(ctx)
   135  	return o
   136  }
   137  
   138  // SetContext adds the context to the get task comments params
   139  func (o *GetTaskCommentsParams) SetContext(ctx context.Context) {
   140  	o.Context = ctx
   141  }
   142  
   143  // WithHTTPClient adds the HTTPClient to the get task comments params
   144  func (o *GetTaskCommentsParams) WithHTTPClient(client *http.Client) *GetTaskCommentsParams {
   145  	o.SetHTTPClient(client)
   146  	return o
   147  }
   148  
   149  // SetHTTPClient adds the HTTPClient to the get task comments params
   150  func (o *GetTaskCommentsParams) SetHTTPClient(client *http.Client) {
   151  	o.HTTPClient = client
   152  }
   153  
   154  // WithID adds the id to the get task comments params
   155  func (o *GetTaskCommentsParams) WithID(id int64) *GetTaskCommentsParams {
   156  	o.SetID(id)
   157  	return o
   158  }
   159  
   160  // SetID adds the id to the get task comments params
   161  func (o *GetTaskCommentsParams) SetID(id int64) {
   162  	o.ID = id
   163  }
   164  
   165  // WithPageSize adds the pageSize to the get task comments params
   166  func (o *GetTaskCommentsParams) WithPageSize(pageSize *int32) *GetTaskCommentsParams {
   167  	o.SetPageSize(pageSize)
   168  	return o
   169  }
   170  
   171  // SetPageSize adds the pageSize to the get task comments params
   172  func (o *GetTaskCommentsParams) SetPageSize(pageSize *int32) {
   173  	o.PageSize = pageSize
   174  }
   175  
   176  // WithSince adds the since to the get task comments params
   177  func (o *GetTaskCommentsParams) WithSince(since *strfmt.DateTime) *GetTaskCommentsParams {
   178  	o.SetSince(since)
   179  	return o
   180  }
   181  
   182  // SetSince adds the since to the get task comments params
   183  func (o *GetTaskCommentsParams) SetSince(since *strfmt.DateTime) {
   184  	o.Since = since
   185  }
   186  
   187  // WriteToRequest writes these params to a swagger request
   188  func (o *GetTaskCommentsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   189  
   190  	if err := r.SetTimeout(o.timeout); err != nil {
   191  		return err
   192  	}
   193  	var res []error
   194  
   195  	// path param id
   196  	if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil {
   197  		return err
   198  	}
   199  
   200  	if o.PageSize != nil {
   201  
   202  		// query param pageSize
   203  		var qrPageSize int32
   204  
   205  		if o.PageSize != nil {
   206  			qrPageSize = *o.PageSize
   207  		}
   208  		qPageSize := swag.FormatInt32(qrPageSize)
   209  		if qPageSize != "" {
   210  
   211  			if err := r.SetQueryParam("pageSize", qPageSize); err != nil {
   212  				return err
   213  			}
   214  		}
   215  	}
   216  
   217  	if o.Since != nil {
   218  
   219  		// query param since
   220  		var qrSince strfmt.DateTime
   221  
   222  		if o.Since != nil {
   223  			qrSince = *o.Since
   224  		}
   225  		qSince := qrSince.String()
   226  		if qSince != "" {
   227  
   228  			if err := r.SetQueryParam("since", qSince); err != nil {
   229  				return err
   230  			}
   231  		}
   232  	}
   233  
   234  	if len(res) > 0 {
   235  		return errors.CompositeValidationError(res...)
   236  	}
   237  	return nil
   238  }