github.com/go-swagger/go-swagger@v0.31.0/examples/cli/client/operations/put_test2766_parameters.go (about)

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